Higher Order Functions taking predicates as arguments

(Some of these are themselves predicates.)

some(is_prime, range(10,20)) ==> 1

some(is_prime, range(8,10)) ==> 0

 

Complementary to some  is no


keep(P,L) = the list of items in L satisfying P

drop(P,L) = the list of items in L not satisfying P

find(P,L) = the suffix of L beginning with the first  item satisfying P

If there is no such suffix, the result is

[ ].


find is similar to keep, except keep locates all items


Use first after find, to get actual item.

 

To Next Slide To Previous Slide To Contents