I would like to find the entries with 4 adjacent cells (horizontally or 
vertically) ?

Is this the right way to do this ? I don't think so, since my solution 
 seems to be very slow. Evaluating in LightTable takes about 10 seconds.

(def matrix [
             {:row 1
              :col 1}
             {:row 1
              :col 2}
             {:row 1
              :col 3}
             {:row 1
              :col 4}

             {:row 2
              :col 1}
             {:row 3
              :col 1}
             {:row 4
              :col 1}
             
             {:row 3
              :col 2}
             ])

(defn succo [row col row-offset col-offset]
  (fresh [?pm ?row ?col] 
    (membero  ?pm matrix)
    (featurec ?pm  {:row ?row :col ?col})
    (fd/eq (= ?col (+ col col-offset)))
    (fd/eq (= ?row (+ row row-offset)))))

(run* [q] 
  (fresh [?pm ?row ?col] 
       (featurec ?pm  {:row ?row :col ?col})
       (conde
           [(succo ?row ?col 0  1)(succo ?row ?col 0  2)(succo ?row ?col 0 
 3)]
           [(succo ?row ?col 1  0)(succo ?row ?col 2  0)(succo ?row ?col 3 
 0)])          
       (== q [?pm])
       (membero ?pm matrix)))

Regards
  Roger

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to