Thursday, May 11, 2017

Cycle elements of a list

Cycle the first element of a list to the end of the list.
Optionally repet recursively.

Usage:
my_list
=shuffle([1,2,3,4,5,6,7,8]);

function shuffle(list,l=1)=
let(c=concat( [for(i=[1:len(list)-1])list[i]],[list[0]]))
l>0?
 shuffle(c,l-1)
 :c
;

No comments:

Post a Comment