Re: seeking a lazy way to interleave a constant

2012-04-10 Thread David Powell
 As an aside.. I just looked at the source for this, what does the :static
tag in the metadata do?

From what I can make out... nothing.  I think it is left over from an
experiment to improve var lookup times prior to dynamic binding being
disabled by default.

-- 
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

Re: seeking a lazy way to interleave a constant

2012-04-10 Thread Alan Malloy
On Apr 10, 12:36 am, David Powell d...@djpowell.net wrote:
  As an aside.. I just looked at the source for this, what does the :static

 tag in the metadata do?

 From what I can make out... nothing.  I think it is left over from an
 experiment to improve var lookup times prior to dynamic binding being
 disabled by default.

Confirmed: all of the compiler's interactions with the :static key are
currently commented out.

-- 
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


seeking a lazy way to interleave a constant

2012-04-09 Thread Andrew
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!

-- 
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

Re: seeking a lazy way to interleave a constant

2012-04-09 Thread dennis zhuang
D o you want this?
user= (def x (interleave (iterate inc 1) (repeat 0)))
#'user/x
user= (take 10 x)
(1 0 2 0 3 0 4 0 5 0)

2012/4/10 Andrew ache...@gmail.com

 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!

 --
 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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
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

Re: seeking a lazy way to interleave a constant

2012-04-09 Thread Ben Mabey

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


Re: seeking a lazy way to interleave a constant

2012-04-09 Thread Cedric Greevey
On Mon, Apr 9, 2012 at 10:31 PM, Andrew ache...@gmail.com 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!

user= (interpose 0 [1 2 3 4 5])
(1 0 2 0 3 0 4 0 5)
user=

-- 
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


Re: seeking a lazy way to interleave a constant

2012-04-09 Thread Ben Mabey

On 4/9/12 9:10 PM, Cedric Greevey wrote:

On Mon, Apr 9, 2012 at 10:31 PM, Andrewache...@gmail.com  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!

user=  (interpose 0 [1 2 3 4 5])
(1 0 2 0 3 0 4 0 5)
user=



Ah, I forgot about that one!

As an aside.. I just looked at the source for this, what does the 
:static tag in the metadata do?


(defn interpose
  Returns a lazy seq of the elements of coll separated by sep
  {:added 1.0
   :static true}
  [sep coll] (drop 1 (interleave (repeat sep) coll)))

--
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