Skip to content

Instantly share code, notes, and snippets.

@shirok
Last active August 8, 2022 09:01
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 shirok/705dbdda4e618fee5cac291883c57de1 to your computer and use it in GitHub Desktop.
Save shirok/705dbdda4e618fee5cac291883c57de1 to your computer and use it in GitHub Desktop.
(define threes '#0=(#f #f #t . #0#))
(define fives '#1=(#f #f #f #f #t . #1#))
(define digits '#2=(#\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9 . #2#))
(define one (list (cdr digits)))
(define (inc num)
(if (eqv? (caar num) #\9)
(if (null? (cdr num))
(cons digits one)
(cons digits (inc (cdr num))))
(cons (cdar num) (cdr num))))
(define (print-num num)
(for-each (^d (display (car d))) (reverse num))
(newline))
(define (fizzbuzz)
(let loop ((num one) (threes threes) (fives fives))
(if (car threes)
(if (car fives)
(print "FizzBuzz")
(print "Fizz"))
(if (car fives)
(print "Buzz")
(print-num num)))
(loop (inc num) (cdr threes) (cdr fives))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment