Database Reference
In-Depth Information
~(second parameter)])]
:seq (let [name (second parameter)]
(apply concat
(map-indexed
(fn [i flag]
'[~flag (nth ~name ~i)])
(first parameter))))
'[~(first parameter)
(~(last parameter) ~(second parameter))])
;; [option-str variable-name default-value flag
;; option]
;; ["-B" distance-of :node-length :flag-equal
;; :branch-length]
5 (condp = (nth parameter 3)
:flag-equal '[(when (= ~(second parameter)
~(last parameter))
~(first parameter))]
:predicate '[(when ~(last parameter)
[~(first parameter)
~(second parameter)])])))
3.
Now we can create a macro that takes a name for the wrapper function, a class
and a method for it, and a sequence of parameter vectors. It then deines the
analysis as a function:
(defmacro defanalysis
[a-name a-class a-method parameters]
'(defn ~a-name
[dataset# &
;; The variable-names and default-values are
;; used here to build the function's
;; parameter list.
{:keys ~(mapv second parameters)
:or ~(into {}
(map #(vector (second %) (nth % 2))
parameters))}]
;; The options, flags, and predicats are used to
;; construct the options list.
(let [options# (->options
~@(mapcat analysis-parameter
parameters))]
 
Search WWH ::




Custom Search