Re: lazy-seq and somewhat greedy apply

2016-06-03 Thread Jason Wolfe
In case it's useful, here is a fully lazy variant of 'apply concat': https://github.com/plumatic/plumbing/blob/master/src/plumbing/core.cljx#L179 -Jason On Friday, June 3, 2016 at 2:26:43 AM UTC+8, Andy L wrote: > > Hi, > > I have a riddle I am not sure how to solve: > ``` > user=> (defn

Re: lazy-seq and somewhat greedy apply

2016-06-02 Thread Andy L
> 1- concat is defined to have 4 different arities: 0-arg, 1-arg, 2-arg, > 3+args. In order to figure out which arity to use, apply has to realize at > least as many elements as the minimum number of args required by the > largest arity, which in this case is 3 > 2- apply has a small bug that

Re: lazy-seq and somewhat greedy apply

2016-06-02 Thread Nicola Mometto
Two things at play here: 1- concat is defined to have 4 different arities: 0-arg, 1-arg, 2-arg, 3+args. In order to figure out which arity to use, apply has to realize at least as many elements as the minimum number of args required by the largest arity, which in this case is 3 2- apply has a

lazy-seq and somewhat greedy apply

2016-06-02 Thread Andy L
Hi, I have a riddle I am not sure how to solve: ``` user=> (defn just-a-demo-seq[] (println "in just-a-demo-seq") [1 2 3 4 5 6 7 8 9]) #'user/just-a-demo-seq user=> (def do-not-print-it (apply concat (repeatedly just-a-demo-seq))) in just-a-demo-seq in just-a-demo-seq in just-a-demo-seq in