declare fun {Filter L F} case L of nil then nil [] X|Lr then if {F X} then X|{Filter Lr F} else {Filter Lr F} end end end