Converting to a HOP-style iterator left as an exercise.
(defn lazy-triangle ([] (cons [1] (lazy-triangle [1]))) ([row] (let [pairs (partition 2 1 row) next-row (concat [1] (map #(apply + %) pairs) [1])] (lazy-seq (cons (vec next-row) (lazy-triangle next-row)))))) ;; ;; user=> (pprint (take 10 (lazy-triangle))) ;; ([1] ;; [1 1] ;; [1 2 1] ;; [1 3 3 1] ;; [1 4 6 4 1] ;; [1 5 10 10 5 1] ;; [1 6 15 20 15 6 1] ;; [1 7 21 35 35 21 7 1] ;; [1 8 28 56 70 56 28 8 1] ;; [1 9 36 84 126 126 84 36 9 1]) ;;
The cake is a lie.
The cake is a lie.
The cake is a lie.
In reply to Re: problem in my sub partition
by Fletch
in thread problem in my sub partition
by PhillipHuang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |