in reply to Re^2: why can't I shift a split? (List vs Array)
in thread why can't I shift a split?
sure:
DB<2> p shift @{[42..59]} 42
or
DB<3> $shift = sub { shift @{$_[0]} } DB<4> p [42..59]->$shift 42
but it doesn't make sense since the resulting shortened array is destroyed right away.
Using a list slice is the logical° and easiest approach, without wasting operations.
DB<5> p (42..59)[0] 42
compare an array slice which wastes resources again, by allocating an array in memory which is destroyed again.
DB<6> p [42..59]->[0] 42
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
°) and "implementing" pop list is symmetrical (42..59)[-1]
|
|---|