File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 167167 (memo x d out)))))
168168
169169; ;; Frame 4-24
170- #_ (defn rembero
170+ (defn rembero2
171171 " Succeeds when out equals l with the first occurrence of x removed."
172172 [x l out]
173173 (conde
174174 ((emptyo l) (== () out))
175175 ((eq-caro l x) (resto l out))
176176 (s# (fresh [a d res]
177177 (resto l d)
178- (rembero x d res)
178+ (rembero2 x d res)
179179 (firsto l a)
180180 (conso a res out)
181181 ))))
Original file line number Diff line number Diff line change 721721 (fresh [y z]
722722 (rembero y (list y 'd z 'e) (list y 'd 'e))
723723 (== (list y z) r)))))
724+
725+ ; ; Resolve this mystery by implementing our own rembero, called
726+ ; ; rembero2, in the file utils.clj, according to the guidelines in
727+ ; ; Frame 4-24. TODO: examine the implementation of "rember" in
728+ ; ; clojure.core/logic.
729+ (test/is (=
730+ '([(d d) d d] [(d d) d d] [(_0 _0) _0 _0] [(e e) e e]
731+ ) (run* [r y z]
732+ (rembero2 y (list y 'd z 'e) (list y 'd 'e))
733+ (== (list y z) r))))
724734)
You can’t perform that action at this time.
0 commit comments