[back]

Filter Any

Implement the function

val filter_any : ('a -> 'b -> bool) -> 'a list -> 'b list -> 'b list

so that filter_any f l r is the members x of r — in order — for which there is some member a of l such that f a x is true.

Examples

let l = [1;2;3;4;5;6;7]
let _ = assert (filter_any (>) [4;2] l = [1;2;3])
let _ = assert (filter_any (<) [4;2] l = [3;4;5;6;7])
let _ = assert (filter_any (=) [4;2] [1;2;3] = [2])