Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
23
Task/Stack/Dyalect/stack.dyalect
Normal file
23
Task/Stack/Dyalect/stack.dyalect
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
type Stack() {
|
||||
var xs = []
|
||||
}
|
||||
|
||||
func Stack.IsEmpty() => this!xs.Length() == 0
|
||||
|
||||
func Stack.Peek() => this!xs[this!xs.Length() - 1]
|
||||
|
||||
func Stack.Pop() {
|
||||
var e = this!xs[this!xs.Length() - 1]
|
||||
this!xs.RemoveAt(this!xs.Length() - 1)
|
||||
return e
|
||||
}
|
||||
|
||||
func Stack.Push(item) => this!xs.Add(item)
|
||||
|
||||
var stack = Stack()
|
||||
stack.Push(1)
|
||||
stack.Push(2)
|
||||
print(stack.Pop())
|
||||
print(stack.Peek())
|
||||
stack.Pop()
|
||||
print(stack.IsEmpty())
|
||||
Loading…
Add table
Add a link
Reference in a new issue