I would simply use a Dequeue, like 'fifo'.

On Sun, Apr 21, 2019, 19:44 C K Kashyap <ckkash...@gmail.com> wrote:

> Thanks Alex! - that's the kindest "cut" :)
> Regards,
> Kashyap
>
> On Sun, Apr 21, 2019 at 10:24 AM Alexander Burger <a...@software-lab.de>
> wrote:
>
>> Hi Kashyap,
>>
>> > (de batch (l s) # l: input list, s = batch size
>> >  (let ts (* -1 s)
>> > (make
>> > (while (< 0 (length l))
>> > (link (head s l))
>> > (setq l (tail ts l))))))
>> >
>> > I'd love to get some feedback on this.
>>
>> First I would suggest to stick with the convention of upper case local
>> variables, to avoid severe foot damage ;)
>>
>>    (de batch (L S)  # L: input list, S = batch size
>>       (let Ts (* -1 S)
>>          (make
>>             (while (< 0 (length L))
>>                (link (head S L))
>>                (setq L (tail Ts L)) ) ) ) )
>>
>> Then a few improvements:
>>
>>    — Instead of (* -1 S) better use the unary minus (- S) It avoids a
>>      multiplication and just sets a sign bit
>>    — (while (< 0 (length L)) ..) is expensive, as it counts the length of
>> the
>>      list each time. Better use a simple (while L ..)
>>    — 'head' and 'tail' can be replaced by 'cut'
>>
>>
>> With that, we get:
>>
>>    (de batch (L S)  # L: input list, S = batch size
>>       (make
>>          (while L
>>             (link (cut S 'L)) ) ) )
>>
>> ☺/ A!ex
>>
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>

Reply via email to