Thanks everybody.

Meikel : To get the sequence printing logic i tried following code. Makes 
no sense to me.


   (def lazy2 (take 3 (iterate #(do
                                  (cond
                                    (= 0 %) (print "+")
                                    (= 1 %) (print "*")
                                    (= 2 %) (print "$")
                                    :else (print "oh no"))
                                  (inc %)) 0)))

user=> lazy2
(+0 *1 2)

Bad..No $.

Regards
Zubair








On Wednesday, 6 June 2012 07:36:12 UTC-4, Pierre-Henry Perret wrote:
>
> A form like: 
>
> (def lazy2 (map #(str "+" %) (range)))
>
> would work. 
>
> Le mercredi 6 juin 2012 11:24:06 UTC+2, Z.A a écrit :
>>
>> Hi
>>
>> user=> (def   lazy1    (take    3     (iterate    #(do   (print   "+") 
>> (inc   %))    0)))
>> #'user/lazy1
>> user=> lazy1
>> (+0    +1     2)
>>
>> Why am I not getting (+0    +1    +2)   ?
>>
>> Thanks
>> Zubair
>>
>> PS: I am reading chapter 6 of 'The Joy of Clojure' and trying to 
>> understand "rest versus next" , pp 116
>>
>>
> Le mercredi 6 juin 2012 11:24:06 UTC+2, Z.A a écrit :
>>
>> Hi
>>
>> user=> (def   lazy1    (take    3     (iterate    #(do   (print   "+") 
>> (inc   %))    0)))
>> #'user/lazy1
>> user=> lazy1
>> (+0    +1     2)
>>
>> Why am I not getting (+0    +1    +2)   ?
>>
>> Thanks
>> Zubair
>>
>> PS: I am reading chapter 6 of 'The Joy of Clojure' and trying to 
>> understand "rest versus next" , pp 116
>>
>>
On Wednesday, 6 June 2012 07:36:12 UTC-4, Pierre-Henry Perret wrote:
>
> A form like: 
>
> (def lazy2 (map #(str "+" %) (range)))
>
> would work. 
>
> Le mercredi 6 juin 2012 11:24:06 UTC+2, Z.A a écrit :
>>
>> Hi
>>
>> user=> (def   lazy1    (take    3     (iterate    #(do   (print   "+") 
>> (inc   %))    0)))
>> #'user/lazy1
>> user=> lazy1
>> (+0    +1     2)
>>
>> Why am I not getting (+0    +1    +2)   ?
>>
>> Thanks
>> Zubair
>>
>> PS: I am reading chapter 6 of 'The Joy of Clojure' and trying to 
>> understand "rest versus next" , pp 116
>>
>>
> Le mercredi 6 juin 2012 11:24:06 UTC+2, Z.A a écrit :
>>
>> Hi
>>
>> user=> (def   lazy1    (take    3     (iterate    #(do   (print   "+") 
>> (inc   %))    0)))
>> #'user/lazy1
>> user=> lazy1
>> (+0    +1     2)
>>
>> Why am I not getting (+0    +1    +2)   ?
>>
>> Thanks
>> Zubair
>>
>> PS: I am reading chapter 6 of 'The Joy of Clojure' and trying to 
>> understand "rest versus next" , pp 116
>>
>>

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