I know, the title sucks… not sure how to explain what I’m asking, so how about some code?
The setup:
L = [1,2,3,4,5,6,7,8,9].
X = 5.
Y = 10.
Here’s what I’m doing now:
lists:any(fun(Z) when Z == X -> true; (_) -> false end, L). => true
lists:any(fun(Z) when Z == Y -> true; (_) -> false end, L). => false
What I’d like to do is something like this sans the guard statement (I don’t know why, just curious if it’s possible.
I’m wondering if you can do something like this (Yes, I know having X in the fun head makes a local scoped variable):
lists:any(fun(X) -> true; (_) -> false end, L).
This particular one could be written as: