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

v0 source pure

Package piglatin ports the classic "Pig Latin" translator — a staple Go beginner exercise — to gno.land as a reusable...

Readme View source

gno.land/p/moul/x/daily/piglatin/v0

Pig Latin translatorTranslate, TranslateToken.

Pure strings/unicode, fully deterministic. Vowel-start words get way; consonant-start words move the leading consonant cluster to the end and add ay; y is a consonant only as the first letter; capitalization and edge punctuation are preserved.

1import "gno.land/p/moul/x/daily/piglatin/v0"
2
3piglatin.Translate("Hello, world!")   // "Ellohay, orldway!"
4piglatin.TranslateToken("string")     // "ingstray"

Live demo: r/moul/x/daily/piglatindemo · render it at /r/moul/x/daily/piglatindemo/v0.


Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

🧪 Highly experimental — potentially vibe-coded. Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: DISCLAIMER.

Overview

Package piglatin ports the classic "Pig Latin" translator — a staple Go beginner exercise — to gno.land as a reusable pure package.

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.

A live demo of this package (an interactive sentence translator) is at r/moul/x/daily/piglatindemo(/r/moul/x/daily/piglatindemo/v0).

Functions 2

func Translate

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

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 3