Hi Louigi,
On 09/08/18 17:10, Louigi Verona wrote:
Reading the docs. I am not sure if this is a mistake
or not. It says
|#(at % 8 {2 60 7 55})
will yield: |nil nil 60 nil nil nil nil 55 nil nil 60 nil nil nil nil 55
nil ...|
|But shouldn't the amount of nils between 60 and 55 be seven and not four?
What
the `at` function does is sequence events at particular time ticks
modulus the second argument.
So here we are saying take the current tick % and wrap it around at 8:
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 ....
Then the map says "when you hit 2 return 60, and when you hit 7 return 55".
So that's why we get the pattern:
0 1 2 3 4 5 6 7 0 1...
nil nil 60 nil nil nil nil 55 nil nil...
The 60 is appearing at 2 and the 55 is appearing at 7 and so on.
Cheers,
Chris.
--
http://mccormick.cx/