Skip to content

Instantly share code, notes, and snippets.



Last active Dec 19, 2015
What would you like to do?
FizzBuzz in Scheme
(define (fizzbuzz n c)
((lambda(d m g)
(g g 1
(m m l
(lambda(i c)
(d i 15
(if b
(c "FizzBuzz")
(d i 5
(if b
(c "Buzz")
(d i 3
(if b
(c "Fizz")
(c i)))))))))))
(m m l
(lambda(i c)
(c (print i)))
(lambda(m n c)
(c (zero? (modulo m n))))
(lambda(m l f c)
(if (pair? l)
(f (car l)
(m m (cdr l) f
(c (cons i l))))))
(c '())))
(lambda(g i c)
(if (<= i n)
(g g (+ i 1)
(c (cons i l))))
(c '())))))
(fizzbuzz 100 c)))
(use srfi-1) ; for iota
(define (map-cpsfun fun lis)
(if (pair? lis)
(fun (car lis)
(cons elem (map-cpsfun fun (cdr lis)))))
(define (fizzbuzz n)
(lambda(i cont)
(if (zero? (modulo i 5))
(cont (print "Buzz"))
(printi (lambda(cont2) (cont cont2)))))
(if (zero? (modulo i 3))
(begin (display "Fizz")
(lambda(c) (c (print ""))))
(lambda(c) (c (print i))))))
(iota n 1)))
(fizzbuzz 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment