21 lines
388 B
Plaintext
21 lines
388 B
Plaintext
; A package written in the indented syntax, imported by ../main.flan.
|
|
|
|
data Shape
|
|
Circle(r: i64)
|
|
Rect(w: i64, h: i64)
|
|
Empty()
|
|
|
|
fn area(s: Shape) -> i64
|
|
match s
|
|
Circle(r) -> 3 * r * r
|
|
Rect(w, h) -> w * h
|
|
Empty -> 0
|
|
|
|
fn rect(w: i64, h: i64) -> Shape = Shape.Rect{.w w, .h h}
|
|
|
|
fn triangle(n: i32) -> i64
|
|
let sum = i64(0)
|
|
for i in range(n + 1)
|
|
sum += i64(i)
|
|
sum
|