mathperson

37 Reputation

2 Badges

15 years, 149 days

MaplePrimes Activity


These are questions asked by mathperson

tlist := [ [s] ]:
  for j to 4 do
    if tlist[-1,1]=s then
      tlist := [ tlist[], [t,tlist[-1][]] ]
    else
   tlist := [ tlist[], [s,tlist[-1][]] ]
  end if
 end do:
tlist;
 

which gives result

[[s], [t, s], [s, t, s], [t, s, t, s], [s, t, s, t, s]]

 

is there an easier way of writing this?

I have a procedure:

duplicates := proc(L)
local newL,vals,T;
newL:=[x->x];
vals := {[1/2,1/4,3/4]};
for T in L do
if not (T([1/2,1/4,3/4]) in vals) then
vals := vals union { T([1/2,1/4,3/4]) };
newL := [newL[],T]
end if
end do;
return newL
end proc:

Page 1 of 1