slovo/examples/array-direct-scalars.slo
2026-05-22 08:38:43 +02:00

33 lines
686 B
Plaintext

(module main)
(fn i32_second () -> i32
(index (array i32 10 20 30) 1))
(fn i64_local_pick () -> i64
(let values (array i64 3) (array i64 4i64 5i64 6i64))
(index values 2))
(fn f64_third () -> f64
(index (array f64 1.5 2.5 3.5) 2))
(fn bool_local_pick () -> bool
(let flags (array bool 3) (array bool false true false))
(index flags 1))
(test "i32 direct scalar array index"
(= (i32_second) 20))
(test "i64 local direct scalar array index"
(= (i64_local_pick) 6i64))
(test "f64 direct scalar array index"
(= (f64_third) 3.5))
(test "bool local direct scalar array index"
(bool_local_pick))
(fn main () -> i32
(if (bool_local_pick)
(i32_second)
0))