Charles Greathouse on Fri, 21 Jun 2013 15:05:30 +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:Fundamentally you are using the wrong data structure.
> 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.
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.