7 years, 99 days

## something like...

@Carl Love  My attempt to solve the problem is as follows.

```parms:={seq(seq(alpha[i,j],j=0..9),i=1..3)};
abc:=combinat:-choose(parms,3):
tab:=Array(1..nops(abc),1):
for i from 1 to nops(abc) by 1 do
tab[i]:=abc[i]:
end do:

conds:= proc(varCoef::set,vars::name:=alpha)
local T1,T2,res;
#
T1 := table([2=3,3=2,5=6,6=5,7=9,9=7]):
T2 := table([2=3,3=2]):
#
res:=map(u->vars[`if`(assigned(T2[op(1,u)]),T2[op(1,u)],op(1,u)),
`if`(assigned(T1[op(2,u)]),T1[op(2,u)],op(2,u))],
varCoef);
return(res):
end proc:

for i from 1 to nops(abc) by 1 do
k:=ListTools:-Search(conds(tab[i]),tab);
k:=ifelse(k<>0,k,i);
tab[k]:=tab[i]:
end do:

newabc:=convert(tab,set):
```

## the fist element of abc is gone...

@Carl Love Many thanks.   I run your code and found that the first element of abc is not in the resulting list (or set).  The way I see thte search is:  get the first element and find (or not) the one in the list that fits conds and then remove it (if you don't remove it when the search reaches that element, the first one is removed and it ends up without any representative of that set of coefficients).  I have the impression that the result in your code is the list (set) of the elements that don't fit conds at all). Please correct me if I am wrong.

As for the question set-list, the order will matter later. Would set be a better choice?

Conds is the y-z symmetry.

## and thanks again....

@Carl Love Thank you ever so much.

## many thanks and ......

@Carl Love Many thanks.   I am glad to know that I finally got something right.  One final question in this thread: what does [] exactly do?  I know that in the commands above [] moves away from list and in doing that set eliminates redundancy.

## please check if I got it right...

@Carl Love Many thanks.  I changed your example to one of my problems.  I think I got it right but I would like to hear from you.

```parms := [alpha[1, 0], alpha[1, 1], alpha[1, 2], alpha[1, 3], alpha[1, 4], alpha[1, 5], alpha[1, 6], alpha[1, 7], alpha[1, 8], alpha[1, 9], alpha[2, 0], alpha[2, 1], alpha[2, 2], alpha[2, 3], alpha[2, 4], alpha[2, 5], alpha[2, 6], alpha[2, 7], alpha[2, 8], alpha[2, 9], alpha[3, 0], alpha[3, 1], alpha[3, 2], alpha[3, 3], alpha[3, 4], alpha[3, 5], alpha[3, 6], alpha[3, 7], alpha[3, 8], alpha[3, 9]]

S:= parms:
B:=s-> evalb(numelems(convert(map2(op, 1, s),set))=3):
n:=4:
# The Array method:
A:= Array(1..0):
for C in Iterator:-Combination(nops(S),n) do
if B((s:= S[[seq(C+~1)]])) then A,= s fi
od:
L1:= [seq(A)]:
# The embedded loop method:
L2:= [
for C in Iterator:-Combination(nops(S), n) do
if B((s:= S[[seq(C+~1)]])) then s fi
od
]:
```

Could you tell me what ",=" means? Many thanks.

@Carl Love Many thanks.  Please give some time to completely understand your solution.   Meanwhile, can you give away the major syntax additions? I am also running Maple 2020.

The lines

```B1:= (s::set)-> `if`(B(s), s, NULL);
L:= [seq(B1(S[[seq(C+~1)]]), C= Iterator:-Combination(nops(S), 6))]```

don't seem to work. They return

`L:=[ifelse(B({22424170465, 193139816415, 386408307450, 395718860534, 412286285840, 427552056869}), {22424170465, 193139816415, 386408307450, 395718860534, 412286285840, 427552056869}, NULL) .....`

## and if I want to save some of them...

@Carl Love Many thanks.  Two questions if I may:

1) I don't know I get it right, but can you do the same using seq (option 2)?

2) Suppose I want some save some of them using a certain criterion.   Would it faster to save them to a table?  (I know you answered a question a few years ago showing the difference between list, table and (I completely forget) but I can't find it). Many thanks.

## sorry for not making myself clear....

@Kitonum That phrase was referring to the use of subsets.   The main point is to get the subsets with a fixed number of elements one by one without generating them all up front.   When I sent the question I was not aware that nextcomb was available.  Iterator seems a good option too.  Many thanks.

## many thanks...

@acer Many thanks.  That is exactly what I need.   It seems that Iterator:-Combination is another good option.

## that is exactly the command to be avoide...

@Kitonum Many thanks but let us consider combinat:-numbcomb(30,10) = 30045015.  Depending on my previous calculations I will have to test them all and I am not sure if they will fit the memory.

## here we go...

@acer Since you opened the door, here is the problem.  I will take the 3D quadratic form as an illustration.

`f := [x^2*alpha[1, 4]+x*y*alpha[1, 5]+x*z*alpha[1, 6]+y^2*alpha[1, 7]+y*z*alpha[1, 8]+z^2*alpha[1, 9]+x*alpha[1, 1]+y*alpha[1, 2]+z*alpha[1, 3]+alpha[1, 0], x^2*alpha[2, 4]+x*y*alpha[2, 5]+x*z*alpha[2, 6]+y^2*alpha[2, 7]+y*z*alpha[2, 8]+z^2*alpha[2, 9]+x*alpha[2, 1]+y*alpha[2, 2]+z*alpha[2, 3]+alpha[2, 0], x^2*alpha[3, 4]+x*y*alpha[3, 5]+x*z*alpha[3, 6]+y^2*alpha[3, 7]+y*z*alpha[3, 8]+z^2*alpha[3, 9]+x*alpha[3, 1]+y*alpha[3, 2]+z*alpha[3, 3]+alpha[3, 0]]`

To test the symmetry (another problem) I need to swap y with z and vice-versa. That was the problem in the head of this thread.  Suppose now the test for the symmetry y-z in the 3D cubic form

`f1 := [x^3*alpha[1, 10]+x^2*y*alpha[1, 11]+x^2*z*alpha[1, 12]+x*y^2*alpha[1, 13]+x*y*z*alpha[1, 14]+x*z^2*alpha[1, 15]+y^3*alpha[1, 16]+y^2*z*alpha[1, 17]+y*z^2*alpha[1, 18]+z^3*alpha[1, 19]+x^2*alpha[1, 4]+x*y*alpha[1, 5]+x*z*alpha[1, 6]+y^2*alpha[1, 7]+y*z*alpha[1, 8]+z^2*alpha[1, 9]+x*alpha[1, 1]+y*alpha[1, 2]+z*alpha[1, 3]+alpha[1, 0], x^3*alpha[2, 10]+x^2*y*alpha[2, 11]+x^2*z*alpha[2, 12]+x*y^2*alpha[2, 13]+x*y*z*alpha[2, 14]+x*z^2*alpha[2, 15]+y^3*alpha[2, 16]+y^2*z*alpha[2, 17]+y*z^2*alpha[2, 18]+z^3*alpha[2, 19]+x^2*alpha[2, 4]+x*y*alpha[2, 5]+x*z*alpha[2, 6]+y^2*alpha[2, 7]+y*z*alpha[2, 8]+z^2*alpha[2, 9]+x*alpha[2, 1]+y*alpha[2, 2]+z*alpha[2, 3]+alpha[2, 0], x^3*alpha[3, 10]+x^2*y*alpha[3, 11]+x^2*z*alpha[3, 12]+x*y^2*alpha[3, 13]+x*y*z*alpha[3, 14]+x*z^2*alpha[3, 15]+y^3*alpha[3, 16]+y^2*z*alpha[3, 17]+y*z^2*alpha[3, 18]+z^3*alpha[3, 19]+x^2*alpha[3, 4]+x*y*alpha[3, 5]+x*z*alpha[3, 6]+y^2*alpha[3, 7]+y*z*alpha[3, 8]+z^2*alpha[3, 9]+x*alpha[3, 1]+y*alpha[3, 2]+z*alpha[3, 3]+alpha[3, 0]]`

T1 and T2 need to be updated in the routines.   I haven't given much thought on that now but it will be in my mind soon.

## nice comparison...

@acer Many many thanks.  I will certainly take into account your advice.  Since my maple proficiency is as bad as you could see by the questions I sent to the list,  I am afraid that I have a long way to find the cleanest and fastest solution to the problem.

## definitely need help here...

@Carl Love Many thanks.  I need help to understand the last line.  specindex is barely touched in the help file (I am running 2017 and 2020).  And the op part as well.

## definitely to apply for large lists and ...

@acer Many many thanks.  I have thousands of lists like the one in the example.  That one is just to prepare the set of coefficients to be tested for the symmetry y->z in a full 3D quadratic model.  It is my plan to extend that to a higher degree and a higher dimension.  The problem will be now to build T1 and T2 programmatically for all cases.

## great solution...

@Carl Love Many many thanks. I am carefully checking the line after varA. I know what is going on but I think I will never come up with a solution like that.

﻿