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?