Re: choosing k elements from a "set", and concat of vecsmall

Bill Allombert <[email protected]>
Newsgroups gmane.comp.mathematics.pari.user
Message-ID <aGWkl9hvLkX9lo1q@seventeen>
On Wed, Jul 02, 2025 at 03:32:20PM -0500, Hans L wrote:
> I often have a need to loop over all "n choose k" elements from a set.  The
> closest builtin functionality I have found for this  is to use forsubset,
> and then build a vector from that with vector as follows:
> 
> forsubset([#S,k], s0,
>   my(s = vector(k, i, S[s0[i]]));
>   ...
> );

You can do s = vecextract(S,s0); instead.

> Another somewhat related thing I noticed recently which feels like an
> oversight is when that concat is presented with a t_VEC and t_VECSMALL, it
> just inserts the t_VECSMALL as a single element.
> ? concat([1,2,3],Vecsmall([4,5,6]))
> %12 = [1, 2, 3, Vecsmall([4, 5, 6])]

But this would change the semantic of concat.

Cheers,
Bill.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.