This is curried function that examines only the first two list elements.
fun inn list f = f(hd(list), hd(tl(list)));
What I would like to know is any ways that I can go through the rest of the list elements.
I don’t know how I make it recursive.
Can anybody help me?
First remark: never use
hdandtl. Use pattern matching instead.I don’t now what exactly you want your function to do, but here is one that iterates over a list and applies f to every element:
which can be written more concisely as
For what’s it worth, this very function is available in the standard basis library under the name
List.app.