Bill Allombert on Wed, 04 Dec 2024 20:12:56 +0100


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

Re: setunion() on a vector of sets


On Wed, Dec 04, 2024 at 01:51:54PM -0500, Charles Greathouse wrote:
> It wouldn't be hard, I think -- just naively calling fold gives something
> like
> 
> GEN
> setunion0(GEN x, GEN y)
> {
>   if(y) return setunion(x, y);
>   pari_sp ltop = avma;
>   GEN res = genfold(strtofunction("setunion"), gp_call2, x);
>   res = gerepilecopy(ltop, p1);
>   return res;
> }
> 
> and it could always be optimized later if there was a need.

Look for gassoc_proto instead, but this is not optimal either:
the union can be computed in one pass.

But then Max will ask the same for setintersect, setdelta, etc.
This is not sustainable.

Cheers,
Bill.