Commit 777ba1e3e1a7f3279d0d1b41ebd19d9a9f50a927

Thomas de Grivel 2023-07-11T12:59:38

fix readme example

diff --git a/README.md b/README.md
index 7826c2c..445517c 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,18 @@ or either
                    :director "William Cottrell"
                    :director "David Hand"))
 
+(with ((?s ?p ?o))
+  (format t "~&~S ~S ~S~&" ?s ?p ?o))
+FACTS.ANON::MOVIE-0000 :ACTOR "Harison Ford"
+FACTS.ANON::MOVIE-0000 :ACTOR "Rutger Hauer"
+FACTS.ANON::MOVIE-0000 :DIRECTOR "Ridley Scott"
+FACTS.ANON::MOVIE-0000 :IS-A :MOVIE
+FACTS.ANON::MOVIE-0000 :TITLE "Blade Runner"
+FACTS.ANON::MOVIE-0001 :DIRECTOR "David Hand"
+FACTS.ANON::MOVIE-0001 :DIRECTOR "William Cottrell"
+FACTS.ANON::MOVIE-0001 :IS-A :MOVIE
+FACTS.ANON::MOVIE-0001 :TITLE "Snow White"
+=> NIL
 ```
 
 The second version with `?movie` will generate an anonymous symbol prefixed with `movie-`.
diff --git a/anon.lisp b/anon.lisp
index d4e701a..3e53ffa 100644
--- a/anon.lisp
+++ b/anon.lisp
@@ -22,10 +22,10 @@
 (defun anon (&rest sym-hints)
   (let* ((sym (intern
                (with-output-to-string (out)
-                 (write-string (string-upcase (first sym-hints)))
+                 (write-string (string-upcase (first sym-hints)) out)
                  (dolist (sym-hint (rest sym-hints))
                    (write-char #\- out)
-                   (write-string (string-upcase sym-hint))))
+                   (write-string (string-upcase sym-hint) out)))
                (find-package :facts.anon))))
     (labels ((guess (count)
                (multiple-value-bind (n found) (intern
diff --git a/test.lisp b/test.lisp
index 50c63ca..7b8ecde 100644
--- a/test.lisp
+++ b/test.lisp
@@ -23,6 +23,19 @@
 
 (untrace with/0 db-each index-each index-find fact/v-subject fact/v-predicate fact/v-object usl-find usl-each make-fact/v)
 
+(facts:add (?movie :is-a :movie
+                   :title "Blade Runner"
+                   :director "Ridley Scott"
+                   :actor "Harison Ford"
+                   :actor "Rutger Hauer"))
+
+(facts:add (?movie :is-a :movie
+                   :title "Snow White"
+                   :director "William Cottrell"
+                   :director "David Hand"))
+
+(untrace with/0 db-each usl-each usl-find)
+
 (with ((?s ?p ?o))
   (format t "~&~S ~S ~S~&" ?s ?p ?o))
 
diff --git a/usl.lisp b/usl.lisp
index 68ee5ca..e6ea321 100644
--- a/usl.lisp
+++ b/usl.lisp
@@ -272,14 +272,6 @@ L1: 50%, L2: 25%, L3: 12.5%, ..."
                 (usl-compare-fun usl))
            a b))
 
-(defun usl-compare (usl a b)
-  (declare (type usl usl))
-  (let* ((compare-fun (the (function (t t) fixnum)
-                           (usl-compare-fun usl)))
-         (result (funcall compare-fun a b)))
-    (format t "~&USL-COMPARE: ~S ~S ~S => ~S~%" compare-fun a b result)
-    result))
-
 ;;  Find
 
 (defun usl-find (usl value &optional pred)