Last active
August 8, 2022 09:01
-
-
Save shirok/705dbdda4e618fee5cac291883c57de1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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