I have set of function like these,
(defn nmf-kernel [a b])
(defn lin-kernel [a b])
(defn log-kernel [a b])
Then another set of initialization function like these,
(defn fill-random
([a b] "filling matrix random")
([a b c] "filling matrix random with another setting parameter"))
Ok, and i have a scenario :
(defn scenario
[kernel a b c d e f g]
(let [init-fn (if (= eval-kernel nmf-kernel)
(fill-random a b)
(fill-random a b c))))
Question : how can i choose a function over another function idiomatically ? because when i'm using (if (= eval-kernel nmf-kernel))
it feels this method is not elegant. And, how can i design this scenario, when i have 10 kernel function and 10 ways to filling the matrix ?
PS : i have same problem in kernel function creation, but maybe the answer for the kernel function is using protocol in Clojure.
Aucun commentaire:
Enregistrer un commentaire