I'm trying to "double" filter through two lists depending on passing a datatype test painfully without recursion using HOPs. Below is my very-ugly attempt at a solution...
datatype 'a test = Test of ('a -> bool) * string;
fun foo xs lst =
let
fun foo_bar(x, ls) =
let
val tests = (List.filter (fn (Test(f, str)) => (f x)) ls)
in
(List.map (fn (Test(f, str)) => str) tests)
end
in
(List.map (fn x => foo_bar(x, lst)) xs)
end;
allPass: 'a list -> 'a test list -> 'a test list;
allPass [1, 2, 40, 150] [positive, even] should return the string "pos".
Currently, my function is returning a nested list: [["pos"], ["pos even"], ["pos even"], ["pos even"]]. Is there a non-recursive way to extract just "pos" from this result or am I going about solving this problem in entirely the wrong direction?
foofunction, but are using aallPassfunction in you example case. - Jesper.ReenbergList.map. - Jesper.Reenberg