1.14 pattern example 9

Write pattern to select from list [3,-4,5,-2] only the numbers that are negative.

In Maple, we use the form patmatch(X, conditional(patttern,condition))

restart; 
L:=[3,-4,5,-2]; 
map( proc(X) local la; 
     if patmatch(X, conditional(n::integer,n<0),'la') then 
        eval(n,la); 
     else 
        NULL; 
     fi; 
     end proc, L); 
 
 
    [-4, -2]
 

In Mathematica

Cases[{3, -4, 5, -2}, x_ /; x < 0] 
 
    {-4,-2}