Skip to content

Commit

Permalink
Implemented 3-47 through 3-49.
Browse files Browse the repository at this point in the history
  • Loading branch information
candera committed Jul 14, 2011
1 parent 635bd5c commit 60bba2c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/reasoned_schemer/chapter3.clj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -199,4 +199,30 @@
(exist [w x y z] (exist [w x y z]
(loto (llist (list :g :g) (list :e w) (list x y) z)) (loto (llist (list :g :g) (list :e w) (list x y) z))
(== r (list w (list x y) z))))))) (== r (list w (list x y) z)))))))
(deftest p47
(is (= ['((:g :g) (:e :e) (_.0 _.0))
'((:g :g) (:e :e) (_.0 _.0) (_.1 _.1))
'((:g :g) (:e :e) (_.0 _.0) (_.1 _.1) (_.2 _.2))]
(run 3 [out]
(exist [w x y z]
(== (llist (list :g :g) (list :e w) (list x y) z) out)
(loto out))))))

(defn listofo [predo l]
(conde
((emptyo l) s#)
((exist [a]
(firsto l a)
(predo a))
(exist [d]
(resto l d)
(listofo predo d)))))


(deftest p49
(is (= ['((:g :g) (:e :e) (_.0 _.0))
'((:g :g) (:e :e) (_.0 _.0) (_.1 _.1))
'((:g :g) (:e :e) (_.0 _.0) (_.1 _.1) (_.2 _.2))]
(run 3 [out]
(exist [w x y z]
(== out (llist (list :g :g) (list :e w) (list x y) z))
(listofo twinso out))))))

0 comments on commit 60bba2c

Please sign in to comment.