Files
mgmt/examples/lang/polymorphic-lambda.mcl
James Shubin d0ed004b24 examples: lang: Test that each of the mcl examples compiles
We let these rot, so fixup the issues and test them!
2024-07-31 17:29:42 -04:00

20 lines
390 B
Plaintext

import "fmt"
func add($x) { # if this was a lambda, type unification would fail! (not allowed)
$x + $x
}
$num = 2
$out1 = add($num) # 4
print [fmt.printf("%d + %d is %d", $num, $num, $out1),] { # simple math
Meta:autogroup => false,
}
$val = "hello"
$out2 = add($val) # hellohello
print [fmt.printf("%s + %s is %s", $val, $val, $out2),] { # simple concat
Meta:autogroup => false,
}