Hi,
On 25 Nov., 09:40, Sunil S Nandihalli
wrote:
> Thanks Meikel for such an insightful feedback. Its hard to imagine so much
> thought goes into writing trivial looking functions.
There are several interpretations of the word "trivial." One is "easy"
or "simple" (where one could dispute whethe
Thanks Meikel for such an insightfull feedback. Its hard to imagine so much
thought goes into writing trivial looking functions.
Sunil.
On Thu, Nov 25, 2010 at 1:00 PM, Meikel Brandmeyer wrote:
> Hi,
>
> On 25 Nov., 05:06, Sunil S Nandihalli
> wrote:
>
> > (defn every-nth
Hi,
On 25 Nov., 05:06, Sunil S Nandihalli
wrote:
> (defn every-nth [n coll]
> (letfn [(evn [cn s]
> (when s
> (if (= cn 1)
> (lazy-seq (cons (first s) (evn n (next s
> (evn (dec cn) (next s)]
> (evn
On 25 November 2010 16:56, Ken Wesson wrote:
> Eh. This is weird. It seems that (partition n coll) drops the last
> part of coll if it's not a multiple of n in size; e.g. (partition 3 [1
> 2 3 4 5]) yields ((1 2 3)) and not ((1 2 3) (4 5)). (partition n n []
> coll) does do that though.
>
See al
Thanks everybody,
Clojure community is awesome .. and also I just wanted to learn to use
lazy-seq that is why it was written in the way I showed you all.
Thanks again.
Sunil.
On Thu, Nov 25, 2010 at 11:26 AM, Ken Wesson wrote:
> Eh. This is weird. It seems that (partition n coll) drops the las
Eh. This is weird. It seems that (partition n coll) drops the last
part of coll if it's not a multiple of n in size; e.g. (partition 3 [1
2 3 4 5]) yields ((1 2 3)) and not ((1 2 3) (4 5)). (partition n n []
coll) does do that though.
OTOH,
(mapcat identity (partition 1 n coll))
(apply concat (pa
just needed a function for every-nth element in a sequence.. I know it
>>>> can be trivially implemented as ..
>>>> (defn every-nth [n coll]
>>>> (letfn [(evn [cn s]
>>>>(when s
>>>> (if (= cn 1)
>>>&
On Wed, Nov 24, 2010 at 11:53 PM, David Sletten wrote:
>
> On Nov 24, 2010, at 11:45 PM, Ken Wesson wrote:
>
>> On Wed, Nov 24, 2010 at 11:11 PM, Baishampayan Ghose
>> wrote:
>>>> I just needed a function for every-nth element in a sequence.. I know it
>
On Nov 24, 2010, at 11:45 PM, Ken Wesson wrote:
> On Wed, Nov 24, 2010 at 11:11 PM, Baishampayan Ghose
> wrote:
>>> I just needed a function for every-nth element in a sequence.. I know it
>>> can be trivially implemented as ..
>>> (defn every-nth
On Wed, Nov 24, 2010 at 11:11 PM, Baishampayan Ghose wrote:
>> I just needed a function for every-nth element in a sequence.. I know it
>> can be trivially implemented as ..
>> (defn every-nth [n coll]
>> (letfn [(evn [cn s]
>> (when
> I just needed a function for every-nth element in a sequence.. I know it
> can be trivially implemented as ..
> (defn every-nth [n coll]
> (letfn [(evn [cn s]
> (when s
> (if (= cn 1)
> (lazy-seq (cons (fi
Hello everybody,
I just needed a function for every-nth element in a sequence.. I know it
can be trivially implemented as ..
(defn every-nth [n coll]
(letfn [(evn [cn s]
(when s
(if (= cn 1)
(lazy-seq (cons (first s) (evn n (next s
12 matches
Mail list logo