# HG changeset patch # User Steve Losh # Date 1471727752 0 # Node ID e9bd0632eadd2bc6c73dc82df99a3cff8a3eb1ac # Parent ab7de6629c42931cdc9bb29a27f069483a6c285c Add problem 14 from 99PP as a test diff -r ab7de6629c42 -r e9bd0632eadd test/99.lisp --- a/test/99.lisp Sun Jul 24 12:44:54 2016 +0000 +++ b/test/99.lisp Sat Aug 20 21:15:52 2016 +0000 @@ -178,6 +178,8 @@ (list ?)) (?what (f cats dogs)))))) + + ; (define-test p9 ; (with-fresh-database ; (%=) @@ -207,3 +209,22 @@ ; (?what ((a a a)))) ; ((pack (list a a b a) ?what) ; (?what ((a a) (b) (a))))))) + + +(define-test p14 + ;; Duplicate the elements of a list. + (with-fresh-database + (push-logic-frame-with + (fact (duplicate nil nil)) + (rule (duplicate (list* ?x ?rest) (list* ?x ?x ?rest-dup)) + (duplicate ?rest ?rest-dup))) + + (should-return + ((duplicate nil nil) + empty) + ((duplicate (list 1) (list 1 1)) + empty) + ((duplicate (list a b c d) (list a a b b c c d d)) + empty) + ((duplicate ?what (list ?x 2 3 ?y)) + (?what (2 3) ?x 2 ?y 3)))))