3
私は現在、定義されていない数の関数を記述しています。そのため、clojure.coreなどで例を探しました。Clojure:関数定義の詳細を記述する理由はありますか?
あなたはアリティ[FG]、コードの詳細を図2及び図3引数(XYの値のために、見ることができるようにこれは、例えばcomp
(clojure.core)
(defn comp
"Takes a set of functions and returns a fn that is the composition
of those fns. The returned fn takes a variable number of args,
applies the rightmost of fns to the args, the next
fn (right-to-left) to the result, etc."
{:added "1.0"
:static true}
([] identity)
([f] f)
([f g]
(fn
([] (f (g)))
([x] (f (g x)))
([x y] (f (g x y)))
([x y z] (f (g x y z)))
([x y z & args] (f (apply g x y z args)))))
([f g & fs]
(reduce1 comp (list* f g fs))))
の定義であり、x 、y、z)に直接ジャンプしてもかまいません([x & args])。
パフォーマンスの理由がありますか?それとも大会ですか? apply
を呼び出すとパフォーマンスに影響する可能性があると私は思います。私たちは、一般的に、ほとんどの3D機能と実際のLIFで2つの関数の合成に使用
は、多分それはそのためです。
おかげ
おかげで、私は、生産機能の頻繁アリティに同じ使用します –