1: #>To get every nth element out of a list, use grep (one of the most under-appreciated built-ins?).</p>
2:
3: (For every fourth element in @List)
4: grep {not ++$i % 4} @List;
5:
6:
7: #(To skip every fifth element)
8: grep {++$i % 5} (1..50)</code>
9:
10: #Simple, but it makes a cool one-liner if you need it...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Get every nth element
by Adam (Vicar) on May 05, 2000 at 00:34 UTC | |
by mdillon (Priest) on May 08, 2000 at 20:01 UTC | |
|
RE: Get every nth element
by Anonymous Monk on May 04, 2000 at 11:10 UTC |