On 4/9/12 8:31 PM, Andrew wrote:
Given a lazy sequence of numbers is there a way to interleave a constant and get another lazy sequence? Say the first sequence is 1 2 3 4 ... I'd like the second sequence to be 1 0 2 0 3 0 4 0 ....

Thanks in advance!


Yep, and it is even called interleave. :)

clojure.core=> (interleave [1 2 3 4] (repeat 0))
(1 0 2 0 3 0 4 0)
clojure.core=> (doc interleave)
-------------------------
clojure.core/interleave
([c1 c2] [c1 c2 & colls])
  Returns a lazy seq of the first item in each coll, then the second etc.
nil
clojure.core=> (doc repeat)
-------------------------
clojure.core/repeat
([x] [n x])
  Returns a lazy (infinite!, or length n if supplied) sequence of xs.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to