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

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

render_example_test.gno

1.56 Kb · 39 lines
 1package piglatindemo
 2
 3// ExampleRender pins the realm's Render output as a testable example.
 4func ExampleRender() {
 5	print(Render(""))
 6	// Output:
 7	// # Pig Latin
 8	//
 9	// Demo of the [`p/moul/x/daily/piglatin`](/p/nym-moultest123/x/daily/piglatin/v0) library — a tiny port of the classic **Pig Latin** translator (the go-to beginner exercise). Pure `strings`/`unicode`, fully deterministic.
10	//
11	// ## Rules
12	//
13	// 1. Word starts with a **vowel** → append `way`. `apple` → `appleway`
14	// 2. Word starts with **consonant(s)** → move the leading consonant cluster to the end, then add `ay`. `string` → `ingstray`
15	// 3. `y` is a consonant only as the first letter (`yellow` → `ellowyay`); otherwise a vowel (`myth` → `ythmay`).
16	// 4. **Capitalization** is preserved: `Hello` → `Ellohay`, `NASA` → `ASANAY`.
17	// 5. **Punctuation** glued to a word stays put: `Hello,` → `Ellohay,`.
18	//
19	// ## Try it
20	//
21	// Append a sentence to the path — spaces are fine:
22	//
23	// - [`/hello world`](/r/nym-moultest123/x/daily/piglatindemo/v0:/hello world) → `ellohay orldway`
24	// - [`/The quick brown fox`](/r/nym-moultest123/x/daily/piglatindemo/v0:/The quick brown fox) → `Ethay uickqay ownbray oxfay`
25	// - [`/I love Gno!`](/r/nym-moultest123/x/daily/piglatindemo/v0:/I love Gno!) → `Iway ovelay Ognay!`
26	//
27	// ## Examples
28	//
29	// | Input | Pig Latin |
30	// |---|---|
31	// | `pig` | `igpay` |
32	// | `banana` | `ananabay` |
33	// | `smile` | `ilesmay` |
34	// | `eat` | `eatway` |
35	// | `yellow` | `ellowyay` |
36	// | `myth` | `ythmay` |
37	// | `Hello,` | `Ellohay,` |
38	// | `GNO` | `OGNAY` |
39}