Explain Pascal's lazy triangle in Clojure

I came across this elegant implementation of the Pascal triangle, which uses a lazy sequence.

(def pascal (iterate (fn [prev-row] (->> (concat [[(first prev-row)]] (partition 2 1 prev-row) [[(last prev-row)]]) (map (partial apply +) ,,,))) [1M])) 

Can someone help me understand ,,, in this context? I tried using macroexpand , but that did not lead me far. I also know that this is not required, but I want to know what ,,, means.

+8
functional-programming clojure
source share
1 answer

Commas are treated as spaces in Clojure, so Reader completely ignores ,,, . The reason is to make the code more readable to people.

In this context, the macro ->> inserts (concat ...) at the last call position in (map ...) , that is, in the position ,,, .

,,, usually used with macros -> and ->> to make the code more readable, but actually does nothing.

+13
source share

All Articles