Question: Recursive

Question:Recursive

Steph123 92 Maple

Hi,

 

I have a list of smaller lists. E.g.

A:=[[a,b],[b,c],[b,c,c],[d,c,c]]
 

I want to write a code that views any elements where all but the first element in the smaller list agree and gets rid of spares. So in A I would want to get rid of [b,c,c] (or [d,c,c]- I don't care which one). I wrote:

 

epi:=proc(A,l,j)
if equal([[l]],[[j]])=false and equal([[seq(A[l][m],m=2..nops(A))]],[[seq(A[j][m],m=2..nops(A))]])=true then RETURN(subsop(l=NULL,A)) end if; end;

But this doesn't do it recursively. Ideally I want to do this for all l and j between 1 and nops(A) and save the new set each time. I'm not sure what the best way to do this is. Can anyone help?


 

 

 

Please Wait...