Skip to content

Instantly share code, notes, and snippets.

@rightfold
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rightfold/27f8f3da20533a6f4092 to your computer and use it in GitHub Desktop.
Save rightfold/27f8f3da20533a6f4092 to your computer and use it in GitHub Desktop.
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