Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 52 lines (40 sloc) 0.997 kb
78b4c7f9 »
2011-09-30 Added a namespace for some seq logic fns
1 (ns logic-examples.seq
2 (:refer-clojure :exclude [inc reify ==])
a5148fb6 »
2011-10-03 appendo examples
3 (:use [clojure.core.logic minikanren prelude nonrel match disequality]
4 [logic-examples.arithmetic]))
78b4c7f9 »
2011-09-30 Added a namespace for some seq logic fns
5
6 (defne prefixo [x y]
7 ([[?a . ?xs] [?a . ?ys]] (prefixo ?xs ?ys))
8 ([[] ?ys]))
9
a5148fb6 »
2011-10-03 appendo examples
10 (defn prefixo2 [x y]
11 (fresh [a]
12 (appendo x a y)))
13
78b4c7f9 »
2011-09-30 Added a namespace for some seq logic fns
14 (defne suffixo [x y]
15 ([_ [?b . x]])
16 ([_ [?b . ?ys]] (suffixo x ?ys))
17 ([[] ?ys]))
18
a5148fb6 »
2011-10-03 appendo examples
19 (defn suffixo2 [x y]
20 (fresh [a]
21 (appendo a x y)))
22
23 (defn sublisto [x y]
24 (fresh [a]
25 (prefixo a y)
26 (suffixo x a)))
27
28 (defn sublisto2 [x y]
29 (fresh [a b c]
30 (appendo a b y)
31 (appendo x c b)))
32
33 (defn my-membero [x y]
34 (fresh [a b]
35 (appendo a (llist x b) y)))
36
37 (defn lasto [x y]
38 (fresh [a]
39 (appendo a [x] y)))
40
41 (defn adjacent [x y z]
42 (fresh [a b]
43 (appendo a (llist x y b) z)))
44
45 (defne reverseo [xs ys]
eba504d4 »
2011-10-12 Fixed problems in numeric comparisons and some seq fns
46 ([[] []])
a5148fb6 »
2011-10-03 appendo examples
47 ([[?x . ?xs] _]
78b4c7f9 »
2011-09-30 Added a namespace for some seq logic fns
48 (fresh [a]
a5148fb6 »
2011-10-03 appendo examples
49 (reverseo ?xs a)
50 (appendo a [?x] ys))))
78b4c7f9 »
2011-09-30 Added a namespace for some seq logic fns
51
Something went wrong with that request. Please try again.