2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,21 +1,20 @@
Enqueue := function(v, x)
Add(v[1], x);
Add(v[1], x);
end;
Dequeue := function(v)
local n, x;
n := Size(v[2]);
if n = 0 then
v[2] := Reversed(v[1]);
v[1] := [ ];
n := Size(v[2]);
if n = 0 then
return fail;
fi;
fi;
return Remove(v[2], n);
if IsEmpty(v[2]) then
if IsEmpty(v[1]) then
return fail;
else
v[2] := Reversed(v[1]);
v[1] := [];
fi;
fi;
return Remove(v[2]);
end;
# a new queue
v := [[], []];