in reply to Permutations question

Flattening things appropriately was the bugaboo.
use strict; use warnings; use Data::Dumper; my $params = [ [ 2, 3, 4 ], 5, [ 6, 7, 8 ], 9 ]; sub get_numbers{ my $array = shift; my ($car, @cdr) = @$array; ref $car or $car = [$car]; @cdr or return $car; [ map { my $n = $_; map {[$n, (ref $_ ? @$_ : $_)] } @{get_numbers(\@cdr)}; } @$car ]; } print Dumper(get_numbers($params));

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: Permutations question
by RazorbladeBidet (Friar) on Feb 22, 2005 at 17:52 UTC
    That does it... thanks !
    --------------
    It's sad that a family can be torn apart by such a such a simple thing as a pack of wild dogs