Items tagged with member

Hy

I have a list

A:=[[2,1],[1,2],[3,5],[7,6]]

I want to be able to tell what position the element [3,5] is in the list

I'm using

member([3,5],A,'t')

is there anything faster

maybe instead of storing as a list, I can use rtables or something?

thankyou for your time

Eight matrices inside the list J:

J := [Matrix([[1, 0], [0, 1]]), Matrix([[0, -I], [-I, 0]]), Matrix([[0, -1], [1, 0]]), Matrix([[-I, 0], [0, I]]), Matrix([[-1, 0], [0, -1]]), Matrix([[0, I], [I, 0]]), Matrix([[0, 1], [-1, 0]]), Matrix([[I, 0], [0, -I]])];

 

Function member identifies J[2] as a member of J and returns its position in j:


member(J[2], J, 'j'); j;

 

Matrix multiplication inside a loop does not have a matrix type:


for i to 1 do for j to 2 do a := J[i].J[j]; member(a, J, 'k'); print(i, j, k, a, whattype(a)) end do end do;

Has anyone any ideia of what is going on?

 

The member function can provide the position of x in table/list s for the first variable

 

e.g.

f:=[a,b,c,a,a];
member(a,f,'p');

will provide p=1

 

If I would like to know the position of all a, [1,4,5], is there any simple way to obtain them? I can do something like

 

n:=0;

for i from 1 to 5 do

 if f[i]='a' then

  n:=n+1;

  p[n]:=i;

 end if;

end do;

 

something like that

Thank you very much

I know how we can add a member to a mathematical set ,for example :

C := NULL;

C := C, V, B, X;

print(C)

V, B, X

but, my problem is that how we can subtract a member from the defined set ?

 

 

Thanks,

 

Page 1 of 1