开发者

What's the Clojure equivalent of inject:into: in Smalltalk?

开发者 https://www.devze.com 2023-02-07 13:39 出处:网络
I\'m trying to learn Clojure but my synapses seem to be hard-wired to Smalltalk. What\'s the equivalent of this function?

I'm trying to learn Clojure but my synapses seem to be hard-wired to Smalltalk.

What's the equivalent of this function?

[:n :k | (1 to: k) inject: 1 into: [:c :i | c * (n - k + i / i)]]
开发者_运维问答
  • this is the binomial coefficient for n, k - also known as "choose" function, representing the number of combinations of n things taken k times


The clojure equivalent of lst inject: s into: f is (reduce f s lst)

0

精彩评论

暂无评论...
验证码 换一张
取 消