Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,33 @@
class STACK{T} is
private attr stack :LLIST{T};
create:SAME is
res ::= new;
res.stack := #LLIST{T};
return res;
end;
push(elt: T) is
stack.insert_front(elt);
end;
pop: T is
if ~stack.is_empty then
stack.rewind;
r ::= stack.current;
stack.delete;
return r;
else
raise "stack empty!\n";
end;
end;
top: T is
stack.rewind;
return stack.current;
end;
is_empty: BOOL is
return stack.is_empty;
end;
end;

View file

@ -0,0 +1,14 @@
class MAIN is
main is
s ::= #STACK{INT};
#OUT + "push values...\n";
s.push(3);
s.push(2);
s.push(1);
s.push(0);
#OUT + "retrieving them...\n";
loop
#OUT + s.pop + "\n";
until!(s.is_empty); end;
end;
end;