44 lines
1,015 B
Text
44 lines
1,015 B
Text
|
|
-- DreamStack built-in functions test
|
||
|
|
-- Tests array, math, string, and conversion builtins
|
||
|
|
|
||
|
|
let items = [1, 2, 3, 4, 5]
|
||
|
|
let name = "DreamStack"
|
||
|
|
|
||
|
|
-- Array operations
|
||
|
|
let count = len(items)
|
||
|
|
let has_three = contains(items, 3)
|
||
|
|
|
||
|
|
-- Math operations
|
||
|
|
let x = floor(3.7)
|
||
|
|
let y = ceil(2.1)
|
||
|
|
let small = min(10, 5)
|
||
|
|
let big = max(10, 5)
|
||
|
|
let clamped = clamp(15, 0, 10)
|
||
|
|
let dist = sqrt(pow(3, 2) + pow(4, 2))
|
||
|
|
|
||
|
|
-- String operations
|
||
|
|
let upper_name = upper(name)
|
||
|
|
let lower_name = lower(name)
|
||
|
|
|
||
|
|
-- Console
|
||
|
|
log("count:", count)
|
||
|
|
log("distance:", dist)
|
||
|
|
|
||
|
|
view main =
|
||
|
|
column [
|
||
|
|
text "Built-in Functions"
|
||
|
|
text "Items: {count}"
|
||
|
|
text "Has 3: {has_three}"
|
||
|
|
text "floor(3.7) = {x}"
|
||
|
|
text "ceil(2.1) = {y}"
|
||
|
|
text "min(10,5) = {small}"
|
||
|
|
text "max(10,5) = {big}"
|
||
|
|
text "clamp(15,0,10) = {clamped}"
|
||
|
|
text "sqrt(3²+4²) = {dist}"
|
||
|
|
text "upper = {upper_name}"
|
||
|
|
text "lower = {lower_name}"
|
||
|
|
button "Push 6" { click: push(items, 6) }
|
||
|
|
button "Pop" { click: pop(items) }
|
||
|
|
text "Length: {len(items)}"
|
||
|
|
]
|