Hi,
I want to shift the first two elementsof a list to the end and this is what i've coded i have to run the proc twice. Is there a simpler way of doing this??? for example
L:=[1,2,3,4,5] => [3,4,5,1,2]
switch2:=proc(N)
local y,li:
li:=N:
for y from 1 to nops(li)-1 do
(li[y],li[y+1]):=(li[y+1],li[y])
od:
li;
end proc:
Is there another simpler way of doing this aswell??
L:=[1,2,3,4,5] => [2,1,4,5,3]
switch:=proc(odd)
local temp, k,odds:
odds:=odd:
temp:=odds[1];
odds[1]:=odds[2];
odds[2]:=temp;
temp:=odds[3];
for k from 3 to nops(odd)-1 do
odds[k] := odds[k+1];od:
odds;
odds[nops(odds)]:=temp:
print(odds);
end proc: