Skip to content

Instantly share code, notes, and snippets.

@jpoler
Created September 3, 2014 21:24
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 jpoler/c10a53101b21b32ccc77 to your computer and use it in GitHub Desktop.
Save jpoler/c10a53101b21b32ccc77 to your computer and use it in GitHub Desktop.
Scheme Code CracklePop
;; range function [start, stop)
(define (range start stop)
(define (iter start stop seq)
(if (= stop start)
(cons start seq)
(iter start (- stop 1) (cons stop seq))))
(iter start (- stop 1) '()))
(define (divides? divisor dividend)
(= (remainder dividend divisor) 0))
(define (modify n)
(cond ((divides? 15 n) "CracklePop")
((divides? 5 n) "Pop")
((divides? 3 n) "Crackle")
(else n)))
(for-each (lambda (n)
(display n)
(newline))
(map modify (range 1 101)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment