Charles Greathouse on Thu, 20 Jun 2013 18:57:18 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

setsearch flags


I just sent in a bug with setsearch, where
> setsearch([1.1,1.3],1.2,1)
and
> setsearch([1.1,2],1.2,1)
give different results despite the element being in the same position in both cases. (Wrapping the vectors with Set() gives the same results.)

I discovered this while writing some code looking for the number of elements in a set in an interval. For that purpose it would be convenient to have a third flag which acts like flag 0 when the element is found and like flag 1 when the element is missing:

> setsearch([5, 7, 9], 6, 2)
%1 = 2
> setsearch([5, 7, 9], 9, 2)
%1 = 3

This would be useful in these situations and shouldn't be hard to implement.

Charles Greathouse
Analyst/Programmer
Case Western Reserve University