32 lines
798 B
Plaintext
32 lines
798 B
Plaintext
;; e as g over a dyn inside an and chain (decision 136): g is bound when e
|
|
;; is not nil, for the rest of the chain and the block.
|
|
|
|
fn pet-name(m)
|
|
if m.pet as pet and pet != "cat"
|
|
pet
|
|
elif m.name as who and who != "bo"
|
|
who
|
|
else
|
|
"nobody"
|
|
|
|
fn first-big(xs, lo)
|
|
let found = when get(xs, 0) as x and x > lo then x
|
|
found
|
|
|
|
fn run(m, xs, a, b)
|
|
println(pet-name(m), pet-name({:pet "cat" :name "bo"}), pet-name({:name "ann"}))
|
|
println(first-big(xs, 0), first-big(xs, 5), first-big([], 0))
|
|
let i = 0
|
|
let total = 0
|
|
while get(xs, i) as x and x > 0
|
|
total += x
|
|
i += 1
|
|
println(total, i)
|
|
if a? and get(xs, 1) as y and a + y > 4
|
|
println(a + y)
|
|
let v = if b as z and z > 1 then z else -1
|
|
println(v)
|
|
|
|
fn main()
|
|
run({:pet "dog" :name "ann"}, [4, 2, 0, 7], 3, nil)
|