-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmini.lisp
68 lines (45 loc) · 1003 Bytes
/
mini.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(in-package #:cl-microkanren)
;; macros for nicer use, and more minikamren style
(macroexpand-1 '(fresh (a q) (== q 5) (== a q)))
(defmacro my-run (syms &body forms)
`(funcall ,(fresh-helper syms forms) empty-state))
(macroexpand-1 '(my-run (a b) (== a b) (== a 5)))
(my-run (a b)
(== a b)
(== a '((1 2 x 4 5))))
(funcall
(fresh (a q)
(== q 5)
(== a q))
empty-state)
(funcall
(fresh (a b)
(== a b)
(== b a))
empty-state)
(macroexpand '(conj+ (== q 5)))
(macroexpand '(conj+ (== q 5) (== q 1)))
(defmacro Zzz (g)
`(lambda (s/c)
(funcall ,g s/c)))
(funcall
(fresh (a b)
(== a 42)
(== b a))
empty-state)
(funcall
(fresh (a b c d)
(conj
(== a 42)
(== b a))
(conj
(== a c)
(== c d)))
empty-state)
(match '((== 1 2) (== 1 5))
((cons a))
((cons a b) (+ a b)))
(macroexpand-1 '(conj+ (== 1 2) (== 3 3) (== 4 4) (== 5 5) (== 6 6)))
(funcall
(conj+ (== 1 2) (== 3 3) (== 4 4) (== 5 5) (== 6 6))
empty-state)