Given an array such as [10,42,45,45,61,61,75,90,1240], how do I find what numbers X is in between? For example, if X = 59, the answers would be [45,45,61,61].
It seems like the select enumerator would be perfect for this, but I can’t figure out how to select all of the elements on either side.
You seem to need the repeated values of the boundaries, don’t you? here is a functional approach just as an example. It’s O(n), so as pointed out by others you better use a O(log(n)) bisection algorithm if you have big input arrays (note: the value to check must be between
xs.minandxs.max):