I have been doing with ml function and got some annoying things.
I will explain it with simple code.
For example if there is a list(int*int) and I want to examine that there are some tuples that contains 3 for the first element.
L = [(1,2),(2,3),(3,5),(3,4)]
so in this list, I want to get 5 and 4.
However, in ML, the function is recursive, so if I write code like this.
fun a(list) =
if #1(hd(list)) = 3 then #2(hd(list))
else a(tl(list))
in this simple function, it can get 5 but not 4 because once it detects that (3,5) is satisfied the condition it returns 5 and the function finishes.
Is there any way to get the 4 as well?
I don’t know ml but basically instead of doing else you need to do this:
(I am gradually editing this response as I learn more about ML 🙂