commit deletes

This commit is contained in:
Ingy döt Net 2013-10-27 23:48:49 +00:00
parent 776bba907c
commit 372c577f83
233 changed files with 0 additions and 6724 deletions

View file

@ -1,56 +0,0 @@
MODE VALUE = STRING; # type of a LINK in this STACK #
MODE LINK = STRUCT(VALUE value, REF LINK next);
MODE STACK = STRUCT(REF LINK first);
STRUCT (
PROC (REF STACK)VOID init,
PROC (REF STACK)BOOL non zero,
PROC (REF STACK, VALUE)VOID append,
PROC (REF STACK)VALUE pop,
PROC (REF STACK)STRING repr,
PROC (REF STACK, STRING)BOOL index error mended
) class stack = (
# PROC init = # (REF STACK self)VOID:
first OF self := NIL,
# PROC non zero = # (REF STACK self)BOOL:
REF LINK(first OF self) ISNT NIL ,
# PROC append = # (REF STACK self, VALUE value)VOID:
first OF self := HEAP LINK := (value, first OF self),
# PROC pop = # (REF STACK self)VALUE: (
IF first OF self IS NIL THEN
STRING message = "pop from empty stack";
IF NOT (index error mended OF class stack)(self, message) THEN
raise index error(message)
FI
FI;
VALUE out = value OF first OF self;
first OF self := next OF first OF self;
out
),
# PROC repr = # (REF STACK self)STRING: (
STRING out := "(",
sep := "";
REF LINK this := first OF self;
WHILE REF LINK(this) ISNT NIL DO
out +:= sep + """" + value OF this + """";
sep := ", ";
this := next OF this
OD;
out+")"
),
# PROC index error mended = # (REF STACK self, STRING message)BOOL:
FALSE # no mend applied #
);
PROC raise index error := (STRING message)VOID: stop;
STACK stack; (init OF class stack)(stack);
[]STRING sample = ("Was", "it", "a", "cat", "I", "saw");
FOR i TO UPB sample DO
(append OF class stack)(stack, sample[i])
OD;
print(((repr OF class stack)(stack), newline))

View file

@ -1,7 +0,0 @@
y=123 /*define a REXX variable, value is 123 */
push y /*pushes 123 onto the stack. */
pull g /*pops last value stacked & removes it. */
q=empty() /*invokes the EMPTY subroutine (below)*/
exit /*stick a fork in it, we're done. */
empty: return queued() /*subroutine returns # of stacked items.*/

View file

@ -1,18 +0,0 @@
class Stack[T]
{
private var items=List[T]()
def isEmpty=items.isEmpty
def peek=items match{
case List() => error("Stack empty")
case head::rest => head
}
def pop=items match{
case List() => error("Stack empty")
case head::rest => items=rest; head
}
def push(value:T)=items=value+:items
}