sub P { # This is so that we don't go off the deep end with recursion : ) return [1,1] if $_[0]==1&&$_[1]==1; return [1] if $_[0]==1; # If there's only one argument, return a list of lists containing # the argument and it's partitions. if (@_==1) { return [@_], P($_[0]-1,1) # Otherwise return a list of lists containing the arguments and # the partitions of the opposites. } else { return [@_], map({ [@$_, $_[1]] } P($_[0])), map({ [$_[0], @$_] } P($_[1])) } }