Skip to content

Commit af497a2

Browse files
author
Russell Mull
committed
Add some useful extended goals
1 parent 7be9124 commit af497a2

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/micro_logic/core.clj

+36
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,39 @@
285285
(if (seq s)
286286
(lcons (first s) (seq->lcons (rest s)))
287287
empty-lcons))
288+
289+
290+
;;; extended goals
291+
292+
(defn conso [first rest seq]
293+
(=== (lcons first rest) seq))
294+
295+
(defn firsto [first seq]
296+
(fresh [rest]
297+
(conso first rest seq)))
298+
299+
(defn resto [rest seq]
300+
(fresh [first]
301+
(conso first rest seq)))
302+
303+
(defn emptyo [x]
304+
(=== empty-lcons x))
305+
306+
(defn nilo [x]
307+
(=== nil x))
308+
309+
(defn repeato [n x]
310+
(conde
311+
[(emptyo x)]
312+
[(fresh [rest]
313+
(conso n rest x)
314+
(repeato n rest))]))
315+
316+
(defn iterateo [gc x]
317+
(conde
318+
[(emptyo x)]
319+
[(fresh [val rest]
320+
(gc val)
321+
(conso val rest x)
322+
(iterateo gc rest))]))
323+

0 commit comments

Comments
 (0)