Created
September 3, 2014 21:24
-
-
Save jpoler/c10a53101b21b32ccc77 to your computer and use it in GitHub Desktop.
Scheme Code CracklePop
This file contains 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
;; 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