I'm looking for help with a problem. I'm trying to write a function that passes both a list and function in ML. Basically what the program is supposed to do is take a list and run each element through the function. If the function returns true, then the element is added to a list and the list returned once the function has finished executing. Here's my code:
fun select(x:list, funct)= (* Define a new function that accepts a list and the prime function as a parameter*)
while (tl(x) not nil) do( (*While the tail is not empty*)
if funct(hd(x)) then (*Then run the function with the the head*)
val l = l::hd(x) (*Adds the head of x to the list *)
(*else 1+tl(x)*));
Any help would be very much appreciated.