--- a/bones-test.asd Fri Jul 22 20:32:51 2016 +0000
+++ b/bones-test.asd Sat Jul 23 13:51:06 2016 +0000
@@ -13,5 +13,6 @@
(:file "circle")
(:file "paip")
(:file "wam")
- (:file "99")))))
+ (:file "99")
+ (:file "taop")))))
--- a/package-test.lisp Fri Jul 22 20:32:51 2016 +0000
+++ b/package-test.lisp Sat Jul 23 13:51:06 2016 +0000
@@ -13,7 +13,10 @@
#:result=
#:results=
#:should-fail
- #:should-return))
+ #:should-return
+ #:%=
+ #:%not
+ #:%append))
(defpackage #:bones-test.paip
(:use
@@ -68,6 +71,28 @@
(:import-from #:bones.utils
#:symbolize))
+(defpackage #:bones-test.taop
+ (:use
+ #:cl
+ #:1am
+ #:bones-test.utils
+ #:bones.quickutils
+ #:bones.wam)
+ (:import-from #:bones.wam
+ #:with-fresh-database
+ #:push-logic-frame-with
+ #:rule
+ #:fact
+ #:facts
+ #:call
+ #:dump-wam-full
+ #:?
+ #:!
+ #:query
+ #:query-all)
+ (:import-from #:bones.utils
+ #:symbolize))
+
(defpackage #:bones-test.circle
(:use
#:cl
--- a/test/99.lisp Fri Jul 22 20:32:51 2016 +0000
+++ b/test/99.lisp Sat Jul 23 13:51:06 2016 +0000
@@ -6,22 +6,6 @@
;;; Solutions to at least a few of these, for testing purposes.
-(defun %= ()
- (push-logic-frame-with
- (fact (= ?x ?x))))
-
-(defun %not ()
- (push-logic-frame-with
- (rule (not ?x) (call ?x) ! fail)
- (fact (not ?x))))
-
-(defun %append ()
- (push-logic-frame-with
- (fact (append nil ?l ?l))
- (rule (append (list* ?x ?rest) ?l (list* ?x ?result))
- (append ?rest ?l ?result))))
-
-
(test p1
;; Find the last element of a list.
(with-fresh-database
@@ -193,3 +177,33 @@
((compress (list (f cats ?) ?what (f ? dogs))
(list ?))
(?what (f cats dogs))))))
+
+; (test p9
+; (with-fresh-database
+; (%=)
+; (%not)
+
+; (push-logic-frame-with
+; (fact (pack nil nil))
+; (fact (pack (list ?x) (list (list ?x))))
+
+; (rule (pack (list* ?x ?tail)
+; (list* (list ?x) ?ptail))
+; (pack ?tail ?ptail)
+; (= ?ptail (list* (list* ?y ?) ?))
+; (not (= ?x ?y)))
+
+; (rule (pack (list* ?h ?tail)
+; (list* (list* ?h ?h ?hs) ?more))
+; (pack ?tail (list* (list* ?h ?hs) ?more))))
+
+; (should-return
+; ((pack nil nil) empty)
+; ((pack (list a) ?what)
+; (?what ((a))))
+; ((pack (list a a) ?what)
+; (?what ((a a))))
+; ((pack (list a a a) ?what)
+; (?what ((a a a))))
+; ((pack (list a a b a) ?what)
+; (?what ((a a) (b) (a)))))))
--- a/test/99.pl Fri Jul 22 20:32:51 2016 +0000
+++ b/test/99.pl Sat Jul 23 13:51:06 2016 +0000
@@ -89,6 +89,18 @@
my_pack([X | Tail], [[X, X | XS] | ResultTail]) :-
my_pack(Tail, [[X | XS] | ResultTail]).
+
+
+
+
+
+
+
+
+
+
+
+
their_pack([],[]).
their_pack([X | Tail], [Chunk | PackedTail]) :-
their_transfer(X, [X | Tail], Remaining, Chunk),
--- a/test/utils.lisp Fri Jul 22 20:32:51 2016 +0000
+++ b/test/utils.lisp Sat Jul 23 13:51:06 2016 +0000
@@ -28,3 +28,18 @@
(t results))
(query-all ,query))))))
+
+;;;; Prolog
+(defun %= ()
+ (push-logic-frame-with
+ (fact (= ?x ?x))))
+
+(defun %not ()
+ (push-logic-frame-with
+ (rule (not ?x) (call ?x) ! fail)
+ (fact (not ?x))))
+(defun %append ()
+ (push-logic-frame-with
+ (fact (append nil ?l ?l))
+ (rule (append (list* ?x ?rest) ?l (list* ?x ?result))
+ (append ?rest ?l ?result))))