Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View 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

View 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]