Created
May 31, 2012 23:59
-
-
Save TimToady/2847343 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub partition(@mask is copy) { | |
my $last = [+] @mask or return [[] xx @mask]; | |
sort gather for @mask.kv -> $k,$v { | |
next unless $v; | |
temp @mask[$k] -= 1; | |
for partition @mask { .take.[$k].push($last) } | |
} | |
} | |
.perl.say for partition [2,0,2]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment