Guest User

Untitled

a guest
Oct 16th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. sub partition(@mask is copy) {
  2. my $last = [+] @mask or return [[] xx @mask];
  3. sort gather for @mask.kv -> $k,$v {
  4. next unless $v;
  5. temp @mask[$k] -= 1;
  6. for partition @mask { .take.[$k].push($last) }
  7. }
  8. }
  9.  
  10. .perl.say for partition [2,0,2];
Add Comment
Please, Sign In to add comment