-
-
Save rightfold/27f8f3da20533a6f4092 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proc hq9plus(code: String) { | |
let $accumulator = 0 | |
for code-points(code) { | |
switch %_ { | |
case 'h'c => outln("Hello, world!") | |
case 'q'c => outln(code) | |
case '9'c => bottles(99) | |
case '+'c => $accumulator += 1 | |
default => | |
} | |
} | |
} | |
proc bottles($n: N) { | |
while $n > 0 { | |
let container = if n == 1 { "bottle" } else { "bottles" } | |
outln([|#{n} #{container} of beer on the wall,|]) | |
outln([|#{n} #{container} of beer,|]) | |
outln("take one down, pass it around,") | |
$n -= 1 | |
} | |
outln("no more bottles of beer on the wall!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment