Skip to content

Instantly share code, notes, and snippets.

@lepoetemaudit
Created August 14, 2015 10:28
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 lepoetemaudit/59bb689b7d069e42ccba to your computer and use it in GitHub Desktop.
Save lepoetemaudit/59bb689b7d069e42ccba to your computer and use it in GitHub Desktop.
Tail-recursive Toki Pona number to string function
let numberToTokiPona num =
let rec addNum num str =
if num >= 2 then addNum (num-2) (str + "twu ")
else if num = 1 then addNum (num-1) (str + "wan ")
else str
if num > 0 then addNum num ""
else "ala"
(numberToTokiPona 19) |> printfn "%s"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment