Skip to content

Instantly share code, notes, and snippets.

@jeancochrane
Last active January 11, 2018 01:56
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 jeancochrane/3bcd2bb2a6518db495f3b11d01df5767 to your computer and use it in GitHub Desktop.
Save jeancochrane/3bcd2bb2a6518db495f3b11d01df5767 to your computer and use it in GitHub Desktop.
A Scheme implementation of CracklePop!
(define (crackle-pop)
(define (iter n)
(let ((divisible-by-3 (= 0 (remainder n 3)))
(divisible-by-5 (= 0 (remainder n 5))))
(cond ((> n 100) "Done printing CracklePop :~)")
(else
(cond ((or divisible-by-3 divisible-by-5)
(if divisible-by-3 (display "Crackle"))
(if divisible-by-5 (display "Pop")))
(else (display n)))
(newline)
(iter (+ n 1))))))
(iter 1))
(crackle-pop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment