RosettaCodeData/Task/Queue-Definition/Elisa/queue-definition-2.elisa

30 lines
506 B
Plaintext

use GenericQueue (QueueofPersons, Person);
type Person = text;
Q = QueueofPersons(25);
Push (Q, "Peter");
Push (Q, "Alice");
Push (Q, "Edward");
Q?
QueueofPersons:[MaxLength = 25;
length = 3;
list = { "Peter",
"Alice",
"Edward"}]
Pull (Q)?
"Peter"
Pull (Q)?
"Alice"
Pull (Q)?
"Edward"
Q?
QueueofPersons:[MaxLength = 25;
length = 0;
list = { }]
Pull (Q)?
***** Exception: Queue Underflow