A basic compiler based off of thejameskyle's super-tiny-compiler

fizzbuzz.mc 623B

12345678910111213141516171819202122232425
  1. (include str maths)
  2. ;
  3. ; def: fizzbuzz(1)
  4. ;
  5. ; Takes an argument and prints the numbers up to and including the argument
  6. ; replacing numbers that are divisible by 3, with Fizz, numbers
  7. ; divisible by 5 with Buzz, and numbers that are divisible by both,
  8. ; with FizzBuzz
  9. ;
  10. (def fizzbuzz
  11. (assign i 1)
  12. (repeat $1
  13. (assign result "")
  14. (if (eq (maths::modulo i 3) 0) (assign result "Fizz"))
  15. (if (eq (maths::modulo i 5) 0) (assign result (str::concat result "Buzz")))
  16. (if (eq result "") (assign result i))
  17. (log result)
  18. (assign i (maths::add i 1))
  19. )
  20. 1)
  21. (if (eq {1} "")
  22. (fizzbuzz 25) | (fizzbuzz {1}))