Last active
November 21, 2023 18:16
-
-
Save nycki93/2bece537b935b667a4f5a61bb74dc39c to your computer and use it in GitHub Desktop.
nift seximal bottles
This file contains hidden or 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
| version: 0.2.1 | |
| depends: ( | |
| nift: 0.0.2 | |
| ) | |
| description: "Sings the '99 bottles' song, but in seximal." | |
| constants: ( | |
| MAX: 35 # fifsy-five | |
| ) | |
| # (a / b / c d e) is shorthand for (a (b (c d e))) | |
| (let small_numbers @/ | |
| "no more" one two three four five | |
| six seven eight nine ten eleven | |
| ) | |
| (let large_numbers @/ | |
| "" "" dozen thirsy foursy fifsy | |
| ) | |
| (let print_number / fn n / | |
| if | |
| (less? n 12) (small_numbers n) | |
| (zero? / mod n 6) (large_numbers / div n 6) | |
| else ( | |
| string | |
| (large_numbers / int / div n 6) | |
| "-" | |
| (small_numbers / mod n 6) | |
| ) | |
| ) | |
| (let capitalize / fn s / | |
| string | |
| (uppercase / s 0) | |
| # like python's slice operator, s[1:] | |
| (s @/ 1) | |
| ) | |
| (let song / fn n i / | |
| if | |
| (zero? i) ( | |
| string | |
| join: "\n" | |
| "No more bottles of beer on the wall," | |
| "no more bottles of beer." | |
| "Go to the store and buy some more," | |
| (print_number n) " bottles of beer on the wall." | |
| ) | |
| else ( | |
| string | |
| join: "\n" | |
| "$(capitalize / print_number i) bottles of beer on the wall," | |
| "$(print_number i) bottles of beer." | |
| "Take one down and pass it around," | |
| "$(print_number / dec i) bottles of beer on the wall." | |
| ) | |
| ) | |
| (string | |
| join: "\n" | |
| */ | |
| each (range MAX -1) / fn i / song MAX i | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment