Last active
October 16, 2017 22:02
-
-
Save lazywithclass/e8c4e9ba703b19f2cc96224bc073d60a to your computer and use it in GitHub Desktop.
Exercises after The Little Schemer chapter 1
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
;; given leq? that checks for lists equality | |
;; complete the following, so that the result is true | |
;; all these exercises can be solved with combinations of | |
;; car, cdr, cons | |
;; be creative! | |
;; this is just an example I solved for you :) | |
;; l -> (1 2 3) | |
;; m -> (0 1 2 3) | |
(leq? l (cdr m)) | |
;; l -> (a b c) | |
;; m -> (42 a b c) | |
(leq? l m) | |
;; l -> (a b 42 c) | |
;; m -> (a b c) | |
(leq? l m) | |
;; l -> (a b c) | |
;; m -> (b c) | |
(leq? l m) | |
;; l -> (a b c) | |
;; m -> (((a b c))) | |
(leq? l m) | |
;; l -> (c b a) | |
;; m -> (a) | |
(leq? l m) | |
;; BONUS! solve also these two and I won't ask a cake next time! | |
;; given l -> (b ((c)) a) | |
;; and having only car at your disposal | |
;; make it so that the following is true | |
(atom? l) | |
;; given l -> () | |
;; and having only cons at your disposal | |
;; make it so that the following is true | |
(leq? (cdr l) (b c (a))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment