Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: problem in my sub partition

by Fletch (Bishop)
on Nov 08, 2010 at 20:09 UTC ( [id://870184]=note: print w/replies, xml ) Need Help??


in reply to problem in my sub partition

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://870184]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-03-19 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found