Find: The perl golf lines necessary to not only produce array @r, the list of items that are removed, but to also to remove those items from @l itself (or at least, to have @l contain items from @a that were not in @r). Order must be maintained in both arrays. Assume that 'use strict' is in play, and you certainly may use additional variables. If you need a test case, use @r=(0..25), with sub c { (($_[0] % 3) == 0); } (e.g. remove multiples of 3).
Update: There's an easy way to do this by going through the list twice. However, for a harder challenge assume that the results of c() may depend on the time when processed, and thus, you only want to evaluate c() once for each item on the original list. (And thanks tye for updates.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Golf: List spliting
by danger (Priest) on Apr 20, 2001 at 23:50 UTC | |
|
(tye)Re: Golf: List spliting
by tye (Sage) on Apr 20, 2001 at 21:59 UTC | |
|
Re: Golf: List spliting
by premchai21 (Curate) on Apr 21, 2001 at 00:58 UTC | |
|
Re: Golf: List spliting
by MeowChow (Vicar) on Apr 21, 2001 at 02:05 UTC | |
by tye (Sage) on Apr 21, 2001 at 02:14 UTC | |
|
Re: Golf: List spliting
by satchboost (Scribe) on Apr 20, 2001 at 21:46 UTC | |
by Masem (Monsignor) on Apr 20, 2001 at 21:50 UTC |