Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
26
Task/Stack/ArkScript/stack.ark
Normal file
26
Task/Stack/ArkScript/stack.ark
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
(let stack (fun () {
|
||||
(mut data [])
|
||||
|
||||
(let push (fun (value) (set data (concat [value] data))))
|
||||
(let popTop (fun () {
|
||||
(let res (head data))
|
||||
(pop! data 0)
|
||||
res }))
|
||||
(let isEmpty? (fun () (empty? data)))
|
||||
|
||||
(fun (&data &push &popTop &isEmpty?) ()) }))
|
||||
|
||||
(let myStack (stack))
|
||||
(myStack.push 1)
|
||||
(myStack.push 2)
|
||||
(myStack.push 3)
|
||||
|
||||
(print myStack.data)
|
||||
|
||||
(print "top: " (myStack.popTop))
|
||||
(print myStack.data)
|
||||
|
||||
(print "empty: " (myStack.isEmpty?))
|
||||
(myStack.popTop)
|
||||
(myStack.popTop)
|
||||
(print "empty: " (myStack.isEmpty?))
|
||||
Loading…
Add table
Add a link
Reference in a new issue