Logo

Programming-Idioms

History of Idiom 135 > diff from v24 to v25

Edit summary for version 25 by daxim:
New Perl implementation by user [daxim]

Version 24

2019-09-26, 16:56:40

Version 25

2019-09-27, 11:03:03

Idiom #135 Remove item from list, by its value

Remove at most 1 item from list items, having value x.
This will alter the original list or return a new list, depending on which is more idiomatic. If there are several occurrences of x in items, remove only one of them.

Idiom #135 Remove item from list, by its value

Remove at most 1 item from list items, having value x.
This will alter the original list or return a new list, depending on which is more idiomatic. If there are several occurrences of x in items, remove only one of them.

Imports
use List::UtilsBy qw(extract_first_by);
Code
extract_first_by { $x eq $_ } @items;
Doc URL
http://p3rl.org/List::UtilsBy#extract_first_by