Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
6
Task/Stack/Rebol/stack-1.rebol
Normal file
6
Task/Stack/Rebol/stack-1.rebol
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
stack: copy []
|
||||
append stack 1 ;== [1]
|
||||
append stack 2 ;== [1 2]
|
||||
take/last stack ;== 2
|
||||
take/last stack ;== 1
|
||||
empty? stack ;== true
|
||||
34
Task/Stack/Rebol/stack-2.rebol
Normal file
34
Task/Stack/Rebol/stack-2.rebol
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
Rebol [
|
||||
Title: "Stack"
|
||||
URL: http://rosettacode.org/wiki/Stack
|
||||
]
|
||||
|
||||
stack: make object! [
|
||||
data: copy []
|
||||
|
||||
push: func [x][append data x]
|
||||
pop: func [/local x][x: last data remove back tail data x]
|
||||
empty: does [empty? data]
|
||||
|
||||
peek: does [last data]
|
||||
]
|
||||
|
||||
; Teeny Tiny Test Suite
|
||||
|
||||
assert: func [code][print [either do code [" ok"]["FAIL"] mold code]]
|
||||
|
||||
print "Simple integers:"
|
||||
s: make stack [] s/push 1 s/push 2 ; Initialize.
|
||||
|
||||
assert [2 = s/peek]
|
||||
assert [2 = s/pop]
|
||||
assert [1 = s/pop]
|
||||
assert [s/empty]
|
||||
|
||||
print [lf "Symbolic data on stack:"]
|
||||
v: make stack [data: [this is a test]] ; Initialize on instance.
|
||||
|
||||
assert ['test = v/peek]
|
||||
assert ['test = v/pop]
|
||||
assert ['a = v/pop]
|
||||
assert [not v/empty]
|
||||
Loading…
Add table
Add a link
Reference in a new issue