Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Exercises after The Little Schemer chapter 1
;; 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
You can’t perform that action at this time.