Skip to content

Instantly share code, notes, and snippets.

@0racle
Created February 25, 2018 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0racle/6be868d7ef38ca6eb2beef9b24387299 to your computer and use it in GitHub Desktop.
Save 0racle/6be868d7ef38ca6eb2beef9b24387299 to your computer and use it in GitHub Desktop.
Gather Take Rots
sub rots($list is copy) {
gather for ^$list {
$list[*] .= rotate;
take $list;
}
}
my @l = ^3;
my $r = rots(@l); say $r; # ([1 2 0] [2 0 1] [0 1 2])
my @r = rots(@l); say @r; # [[0 1 2] [0 1 2] [0 1 2]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment