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

22
Task/Stack/E/stack-1.e Normal file
View file

@ -0,0 +1,22 @@
? def l := [].diverge()
# value: [].diverge()
? l.push(1)
? l.push(2)
? l
# value: [1, 2].diverge()
? l.pop()
# value: 2
? l.size().aboveZero()
# value: true
? l.last()
# value: 1
? l.pop()
# value: 1
? l.size().aboveZero()
# value: false

30
Task/Stack/E/stack-2.e Normal file
View file

@ -0,0 +1,30 @@
def makeStack() {
var store := null
def stack {
to push(x) { store := [x, store] }
to pop() { def [x, next] := store; store := next; return x }
to last() { return store[0] }
to empty() { return (store == null) }
}
return stack
}
? def s := makeStack()
# value: <stack>
? s.push(1)
? s.push(2)
? s.last()
# value: 2
? s.pop()
# value: 2
? s.empty()
# value: false
? s.pop()
# value: 1
? s.empty()
# value: true