diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-03-09 16:03:38 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-03-09 16:03:38 -0500 |
| commit | b04a1b30903636bf97a8e04efe88e8a177855bcb (patch) | |
| tree | d85a765c07c3cc686485d30ef7a4216f4d830cad /test | |
| parent | 42da91936e50ab652d140677689b519fe9deb3fe (diff) | |
Implement lambdas and closures
Diffstat (limited to 'test')
| -rw-r--r-- | test/lambdas.tm | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/test/lambdas.tm b/test/lambdas.tm index 86b4b263..d896ea4b 100644 --- a/test/lambdas.tm +++ b/test/lambdas.tm @@ -1,5 +1,3 @@ - - >> add_one := func(x:Int) x + 1 >> add_one(10) = 11 @@ -10,3 +8,19 @@ >> asdf := add_one >> asdf(99) = 100 + + +func make_adder(x:Int)-> func(y:Int)->Int + return func(y:Int) x + y + +>> add_100 := make_adder(100) +>> add_100(5) += 105 + + +func suffix_fn(fn:func(t:Text)->Text, suffix:Text)->func(t:Text)->Text + return func(t:Text) fn(t)++suffix + +>> shout2 := suffix_fn(Text.upper, "!") +>> shout2("hello") += "HELLO!" |
