Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Perl

Idiom #189 Filter and transform list

Produce a new list y containing the result of the function T applied to all elements e of the list x that match the predicate P.

my @y = map { T($_) } grep { P($_) } @x;

$_ inside grep block represents each element e of array x
(def y 
  (eduction (filter P)
            (map T))
            x)

New implementation...