<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -93,11 +93,40 @@
 							   '(Mr Hulot and I need a vacation))))
   (is (= '{?X (1 2 a b)} (pat-match '((?* ?X) a b (?* ?X)) '(1 2 a b a b 1 2 a b)))))
 
-;; Because we don't have dotted pairs, this test will fail.  This will be addressed
-;; in improved versions
-;;  (is (= '{(?X a long vacation) (?P I)} (pat-match '(?P need . ?X) '(i need a long vacation)))))
+;; Because we want ordering I've gone for the standard list approach used in the PAIP book
+;; An alternative would be to define a sorted-map with keys having some kind of priority
+(defn rule-pattern
+  [rule]
+  (first rule))
 
+(defn rule-responses
+  [rule]
+  (rest rule))
 
+(declare *eliza-rules*)
+
+(defn switch-viewpoint
+  &quot;Change I to you and vice versa, and so on.&quot;
+  [words]
+  (let [substitutions '{I you, you I, me you, am are}]
+    (replace substitutions words)))
+
+(defn random-elt
+  [x]
+  (nth x (rand-int (count x))))
+
+(defn use-eliza-rules
+  &quot;Find a rule to transform the input&quot;
+  [input]
+  (some (fn [rule]
+	  (let [result (pat-match (rule-pattern rule) input)]
+	    (println (rule-responses rule))
+	    (println (switch-viewpoint result))
+	    (when-not (= result fail)
+	      (replace (switch-viewpoint result)
+		       (random-elt (rule-responses rule))))))*eliza-rules*))
+
+;; Oh bum.  I now need to replace this with hash maps
 (def *eliza-rules*
  '((((?* ?x) hello (?* ?y))      
     (How do you do.  Please state your problem.))</diff>
      <filename>ai/uk/co/fatvat/eliza.clj</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ab460f1f7e4d9d38e8dedaad0113e223fec909b5</id>
    </parent>
  </parents>
  <author>
    <name>Jeff Foster</name>
    <email>jeff.foster@acm.org</email>
  </author>
  <url>http://github.com/fffej/ClojureProjects/commit/5a45fe86cebccb7b3ae8cc9dc84ac949a24a4172</url>
  <id>5a45fe86cebccb7b3ae8cc9dc84ac949a24a4172</id>
  <committed-date>2009-06-23T00:28:54-07:00</committed-date>
  <authored-date>2009-06-23T00:28:54-07:00</authored-date>
  <message>Need to replace the rules with {} map syntax rather than a-lists</message>
  <tree>676ee046ece1910c0e4e21ac5c225ce3690c0480</tree>
  <committer>
    <name>Jeff Foster</name>
    <email>jeff.foster@acm.org</email>
  </committer>
</commit>
