The problem is that 'rot' is a "destructive" function, i.e. it modifies
its list argument. You could use 'copy' to avoid this.
I would write
(de split-number (N)
(mapcar format (chop N)) )
(de all-rotations (N)
(let SN (split-number N)
(do (length SN)
(link (copy (rot SN)))
(println SN) ) ) ) )
(two minor optimizations: 'chop' can also directly work on a number, and
'L' is not needed in the loop).
Thanks for the hint for 'chop': I didn't even consider using it on something
else than a string...
As for replacing the 'for' by a 'do', I will confess that I totally forgot about
that one! (I did attempt a 'while' but didn't like the code I got...)
I'm ashamed to say that, after tests, I realized that I didn't need to 'link'
the result of the 'rot', but '(format (pack (rot SN)))'...