|Bill Allombert on Fri, 21 Jun 2013 11:55:40 +0200|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|Re: setsearch flags|
On Thu, Jun 20, 2013 at 01:28:29PM -0400, Charles Greathouse wrote: > My immediate purpose was an implementation of Hooley's Î function, which I > tried to define as: > > Delta(n)=my(d=divisors(n),m=1);for(i=1,#d-1,m=max(setsearch(d,exp(1)*d[i],1)-i,m));m > > For each divisor d < n of n, this finds the number of divisors in the > interval [d, de]. So my vector does consist only of integers. Unfortunately > neither flag gives the desired behavior, since one or both of floor(de) and > floor(de+1) may be in the set. > > Thus my feature request for another flag on setsearch. Fundamentally you are using the wrong data structure. As an abstract data structure, Set are not ordered. You should use vecsort and vecsearch, which allow for arbitrary comparaison function to be used. Cheers, Bill.