Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

piglatin source realm

Package piglatin ports the classic "Pig Latin" translator — a staple Go beginner exercise — to an on-chain gno.land r...

Overview

Package piglatin ports the classic "Pig Latin" translator — a staple Go beginner exercise — to an on-chain gno.land realm.

Rules implemented (the standard English game):

  • A word that starts with a vowel gets "way" appended: "apple" -> "appleway"
  • A word that starts with one or more consonants has that leading consonant cluster moved to the end, followed by "ay": "string" -> "ingstray"
  • "y" acts as a consonant only when it is the first letter of the word ("yellow" -> "ellowyay"); elsewhere it counts as a vowel ("myth" -> "ythmay").
  • Original capitalization of the word is preserved (title-case in, title-case out): "Hello" -> "Ellohay".
  • Trailing/leading punctuation attached to a word is preserved in place: "Hello," -> "Ellohay,".

Everything is pure strings/unicode — deterministic and reproducible on-chain.

Functions 3

func Render

1func Render(path string) string
source

Render is the gnoweb entrypoint (Markdown). Root explains the rules; any other path is treated as a sentence to translate, e.g. Render("/Hello world").

func Translate

Action
1func Translate(sentence string) string
source

Translate applies Pig Latin to every word in the sentence while preserving the original whitespace between words.

func TranslateToken

Action
1func TranslateToken(token string) string
source

TranslateToken translates a single whitespace-delimited token, preserving any punctuation glued to its edges.

Imports 2

  • strings stdlib
  • unicode stdlib

Source Files 2