in reply to Re: head of list + rest of list
in thread head of list + rest of list
shift and splice don't work on lists.
These only work on arrays:
# Haskell programmer: my ($head, @tail) = @array; # Shell programmer my $head = shift @array; my @tail = @array; # Perlfunc Author my $head = splice @array, 0, 1; my @tail = @array;
These work on lists (including arrays):
# Haskell programmer: my ($head, @tail) = list; # Shell programmer my @tail = list; my $head = shift @tail; # Perlfunc Author my @tail = list; my $head = splice @tail, 0, 1;
By the way, there's no need to put $head in list context for this splice.
|
|---|