Files
mgmt/lang/interpret_test/TestAstFunc2/func-math1.txtar
James Shubin 8fffd10280 lang: Port TestAstFunc2 to txtar format
This ports TestAstFunc2 from our home-grown content storage system to
the txtar package. Since a single file can be used to represent the
entire folder hierarchy, this makes it much easier to see and edit
tests.
2023-06-01 16:56:44 -04:00

22 lines
339 B
Plaintext

-- main.mcl --
import "fmt"
# function statement
func sq1($x, $y) {
$y + $x * $x
}
# function expression
$sq2 = func($x, $y) {
$y + $x * $x
}
$x1 = sq1(3, 4) # 3^2 + 4 = 13
$x2 = $sq2(7, -7) # 7^2 + 2 = 42
test fmt.printf("sq1: %d", $x1) {}
test fmt.printf("sq2: %d", $x2) {}
-- OUTPUT --
Vertex: test[sq1: 13]
Vertex: test[sq2: 42]