hermann on Wed, 06 Sep 2023 14:14:21 +0200


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

Re: Python combinations() in GP?


On 2023-09-06 13:43, Aurel Page wrote:
Dear Hermann,

What you want is probably flag=2 in forvec.

Cheers,
Aurel

Thank you, that did the trick!

$ cat combinations.gp
{
  forvec(v=vector(3,i,[1,5]),
    print(v),2);
}
$ gp -q < combinations.gp
[1, 2, 3]
[1, 2, 4]
[1, 2, 5]
[1, 3, 4]
[1, 3, 5]
[1, 4, 5]
[2, 3, 4]
[2, 3, 5]
[2, 4, 5]
[3, 4, 5]
$

Regards,

Hermann.