On Thu, Feb 12, 2009 at 12:22 PM, Meikel Brandmeyer wrote:
> Hi,
>
> Am 12.02.2009 um 18:29 schrieb Mark Volkmann:
>
>> (def f-infinite-seq (map f (iterate inc 0))) ; values 0 through infinity
>>
>> (println "The first is" (first f-infinite-seq))
>> (println "The third is" (nth f-infinite-seq 2))
On Thu, Feb 12, 2009 at 12:22 PM, Meikel Brandmeyer wrote:
> Hi,
>
> Am 12.02.2009 um 18:29 schrieb Mark Volkmann:
>
>> (def f-infinite-seq (map f (iterate inc 0))) ; values 0 through infinity
>>
>> (println "The first is" (first f-infinite-seq))
>> (println "The third is" (nth f-infinite-seq 2))
Hi,
Am 12.02.2009 um 18:29 schrieb Mark Volkmann:
(def f-infinite-seq (map f (iterate inc 0))) ; values 0 through
infinity
(println "The first is" (first f-infinite-seq))
(println "The third is" (nth f-infinite-seq 2))
The result is cached in f-infinite-seq. So as long as you hold
onto the
Here's some simple code that demonstrates evaluation of items in an
infinite, lazy sequence. The function f contains a println side-effect
so I know when it's being called.
(defn f
"square the parameter and divide by 2"
[x]
(println "calculating f of" x)
(/ (* x x) 2.0))
; Create an infi