datascript

Immutable database and Datalog query engine for Clojure, ClojureScript and JS
2018-11-20T09:40:25.025200Z

Why don't both these thing give me the same result?

(d/q '[:find ?a
       :in [[?a]]
       :where
       [(> ?a 2000)]
       [(even? ?a)]
       [(= 1090 (/ ?a 2))]]
     (map vector (range 0 20000)))

(->>
 (range 0 20000)
 (filter #(> % 2000))
 (filter even?)
 (filter #(= 1090 (/ % 2))))

ClashTheBunny 2018-11-20T15:03:00.025600Z

You can't call a function in a function in datascript:

(datascript.core/q '[:find ?a
         :in [[?a]]
         :where
         [(> ?a 2000)]
         [(even? ?a)]
         [(/ ?a 2) ?aover2]
         [(= 1090 ?aover2)]]
       (map vector (range 0 20000)))

1