use LISP qw(cons); # Create linked list (Not an array!) my $list = LISP->new([[1,2,3,4],[5,6,7,8],[9,10,11,12]]); print $list->string; # Prints ((1 2 3 4) (5 6 7 8) (9 10 11 12)) my $mapcarf = LISP->new(\&LISP::Lambda::mapcar); my $listf = LISP->new($list->can('list')); # We probably ought to go for closure on mapcarf and listf # But this is OK for now my $transpose = sub {$mapcarf->apply(cons($listf, shift))}; $list=$transpose->($list); print $list->string; # Prints ((1 5 9) (2 6 10) (3 7 11) (4 8 12)) $list=$transpose->($list); print $list->string; # Prints ((1 2 3 4) (5 6 7 8) (9 10 11 12))