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

Pig Latin

Demo of the p/moul/x/daily/piglatin library — a tiny port of the classic Pig Latin translator (the go-to beginner exercise). Pure strings/unicode, fully deterministic.

Rules

  1. Word starts with a vowel → append way. appleappleway
  2. Word starts with consonant(s) → move the leading consonant cluster to the end, then add ay. stringingstray
  3. y is a consonant only as the first letter (yellowellowyay); otherwise a vowel (mythythmay).
  4. Capitalization is preserved: HelloEllohay, NASAASANAY.
  5. Punctuation glued to a word stays put: Hello,Ellohay,.

Try it

Append a sentence to the path — spaces are fine:

  • [/hello world](/r/moul/x/daily/piglatindemo/v0:/hello world) → ellohay orldway
  • [/The quick brown fox](/r/moul/x/daily/piglatindemo/v0:/The quick brown fox) → Ethay uickqay ownbray oxfay
  • [/I love Gno!](/r/moul/x/daily/piglatindemo/v0:/I love Gno!) → Iway ovelay Ognay!

Examples

Input Pig Latin
pig igpay
banana ananabay
smile ilesmay
eat eatway
yellow ellowyay
myth ythmay
Hello, Ellohay,
GNO OGNAY