Fork me on GitHub
#beginners
<
2016-07-01
>
montanonic06:07:31

Is there a way to check function documentation within the repl?

montanonic06:07:17

I'd be really surprised if there wasn't, given that you can store doc info straight in defn

montanonic06:07:46

Ah, found it, doc in clojure.repl. Awesome.

hrathod13:07:22

@montanonic: there is also a source function to show you the source code of a given function. Very handy.

uwo13:07:52

I’m trying to dry up some queries that all use the same query shape with different attributes.

(defn simple-search-query [attrs]
  [:find '?e
   :in '$ '?term
   :where
   (apply list 'or-join '[?e ?term]
          (map (fn [attr]
                 (let [sym (gensym)]
                   (list 'and ['?e attr sym]
                         [(list 'some.fn/match? '?term sym)])))
               attrs))])

(simple-search-query [:some/name :some/code])
This returns the correct data structure, but I need to quote the result of the simple-search-query fn. My macro/quoting fu is weak. Any suggestions?

uwo16:07:16

the solution was straight forward

(defmacro search-query [attrs] `(quote ~(simple-search-query attrs))).  
On an unrelated note I needed (gensym “?val”) to work with datomic