Re: circR

2016-03-09 Thread Mike
cool, i will replace

> On 9 марта 2016 г., at 10:22, Alexander Burger  wrote:
> 
> Hi Mike,
> 
>> Works as circular list and after reset can count again from the beginning

Re: circR

2016-03-09 Thread Alexander Burger
Hi Mike,

> Works as circular list and after reset can count again from the beginning.
> Used in Threefish implementation.
> ...
> https://bitbucket.org/mihailp/tankfeeder/src/d38de78a9609d31a917ca73f8b8d9fe302afc5b8/circR.l?fileviewer=file-view-default
> 
> Code comments are welcome.

I think you could make it a lot simpler. Instead of keeping a count and
the length, you can keep the whole list:

   (de circR ("Var" Lst)
  (set "Var" (cons (apply circ Lst) Lst)) )

This works because neither (apply circ Lst) nor the later 'pop's are
destructive.

Then 'resetR' is also much simpler:

   (de resetR ("Var")
  (set "Var" (cdr (val "Var"))) )

and 'popR' (and in fact also 'resetR') is not needed at all:

   : (circR 'L (range 1 5))
   -> ((1 2 3 4 5 .) 1 2 3 4 5)

   : L 
   -> ((1 2 3 4 5 .) 1 2 3 4 5)

   : (pop L)
   -> 1

   : (pop L)
   -> 2

   : L  
   -> ((3 4 5 1 2 .) 1 2 3 4 5)

   : (set L (cdr L))  # This can be used instead of 'resetR'
   -> (1 2 3 4 5)

   : L  
   -> ((1 2 3 4 5) 1 2 3 4 5)

   : (pop L)
   -> 1

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


circR

2016-03-08 Thread Mike Pechkin
hi all,

I've create cool abstraction.
Works as circular list and after reset can count again from the beginning.
Used in Threefish implementation.
Usage example:
http://pastebin.com/dwSiNQgu

Code:
https://bitbucket.org/mihailp/tankfeeder/src/d38de78a9609d31a917ca73f8b8d9fe302afc5b8/circR.l?fileviewer=file-view-default

Code comments are welcome.

Mike