Skip to content

Instantly share code, notes, and snippets.

@ympbyc
Created October 10, 2011 00:33
Show Gist options
  • Save ympbyc/1274416 to your computer and use it in GitHub Desktop.
Save ympbyc/1274416 to your computer and use it in GitHub Desktop.
["simple answer for fizzbuzz writtern in JSLisp", "and the jscode code generated by the translator"]
(define fizzbuzz (lambda (i)
(if (== i 101)
""
(if (== (% i 15) 0)
(+ "fizzbuzz," (fizzbuzz (+ i 1)))
(if (== (% i 3) 0)
(+ "fizz," (fizzbuzz (+ i 1)))
(if (== (% i 5) 0)
(+ "buzz," (fizzbuzz (+ i 1)))
(+ (+ (String i) ",") (fizzbuzz (+ i 1))))
)))))
(fizzbuzz 1)
var fizzbuzz = function (i){
return (i == 101) ? "" : ((i % 15) == 0) ? ("fizzbuzz," + (fizzbuzz)((i + 1))) : ((i % 3) == 0) ? ("fizz," + (fizzbuzz)((i + 1))) : ((i % 5) == 0) ? ("buzz," + (fizzbuzz)((i + 1))) : (((String)(i) + ",") + (fizzbuzz)((i + 1)))};
(fizzbuzz)(1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment