I need to do this two very similar exercises in Oz:
*. Write the function {Some L P} that takes a list L and a Boolean function P. It returns true if P returns true for at least one element of L and false otherwise.
*. Write the function {All L P} that returns true if and only if P is true for all the elements in L.
what I'm not sure is if I have a function like this, how can I make it return true or false:
declare
fun{P X} //bolean function
if X==2 then true
else false
end
end
fun{Some L P} //Some function
case L
of nil then nil
[] X|Xr then
if {P X} == true then X|{Some Xr P}
else {Some Xr P}
end
end
end
{Browse {Some [1 2 3] P}}
2 is true, so it has to return true