diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-04-12 13:09:31 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-04-12 13:09:31 -0400 |
| commit | 6c01eef851439549018267fdc439e4884af0c624 (patch) | |
| tree | 0599dd071b8a5effb67e6a87ed1c34777eb8d8c7 /test/lambdas.tm | |
| parent | 17cb6ffd88c4464c513b045f4b06c4e6e46e8f22 (diff) | |
Introducing the main() function
Diffstat (limited to 'test/lambdas.tm')
| -rw-r--r-- | test/lambdas.tm | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/test/lambdas.tm b/test/lambdas.tm index ca2acb5d..a445540b 100644 --- a/test/lambdas.tm +++ b/test/lambdas.tm @@ -1,33 +1,32 @@ ->> add_one := func(x:Int) x + 1 ->> add_one(10) -= 11 - ->> shout := func(msg:Text) say("{msg:upper()}!") ->> shout("hello") - ->> 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!" - func mul_func(n:Int, fn:func(x:Int)->Int)-> func(x:Int)->Int return func(x:Int) n*fn(x) ->> abs100 := mul_func(100, Int.abs) ->> abs100(-5) -= 500 +func main() + >> add_one := func(x:Int) x + 1 + >> add_one(10) + = 11 + + >> shout := func(msg:Text) say("{msg:upper()}!") + >> shout("hello") + + >> asdf := add_one + >> asdf(99) + = 100 + + >> add_100 := make_adder(100) + >> add_100(5) + = 105 + + >> shout2 := suffix_fn(Text.upper, "!") + >> shout2("hello") + = "HELLO!" + + >> abs100 := mul_func(100, Int.abs) + >> abs100(-5) + = 500 |
