What is the best way to check if integer value is present between two integer value?

I have a list of
[[8, 10], [12, 13], [15, 16]].

I want to check if 9 is present in any of them.

Does something like this help?

Enum.any?([[8, 10], [12, 13], [15, 16]], fn [s, e] -> 9 in s..e end)

PS.: I wasn’t sure if you wanted to check if the value 9 is part of the list or in between the range of values. But you can solve both problems in a similar way using Enum.any?/2.

2 Likes

He recently asked a similar question. It was answered in this post. Sounds like Enum.any? should do the trick but the expected output is not clear.

2 Likes

Do you need any extra info compared to your previous post which was almost identical?

Also, what have you tried after going through the answers there? Can we see your latest attempt?

2 Likes