I'm new to Erlang. All I want to do is take a list, loop through each element so I can send them to a function. Cannot find a clear example anywhere.
Example of what I want to do:
Mylist = [a,b,c,d,e,f,g]
for (i in Mylist) {
otherFunction(Mylist[i]);
}
Hope that help :)
func([]) -> ok;
func([H|T]) ->
otherFunction(H),
func(T).
Or you can use list comprehension:
[otherFunction(H) || H <- L].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With