note
Aristotle
<code>#!/usr/bin/perl -w
use strict;
use Data::Dumper;
sub unshift_many {
my $scalar = shift;
unshift @$_, $scalar for @_;
@_;
}
sub combinations {
my ( $array, $len, $start ) = @_;
$start ||= 0;
return unless $len > 0;
return $len == 1
? map [ $_ ], @{ $array }[ $start .. $#$array ]
: map unshift_many( $array->[$_], combinations( $array, $len-1, $_+1 ) ),
$start .. $#$array;
}
$Data::Dumper::Indent=0;
print Dumper( [ combinations [ qw( 1 2 3 4 5 ) ], 3 ] ), "\n";</code>
<p align="right"><em>Makeshifts last the longest.</em></p>
191902
191902