aboutsummaryrefslogtreecommitdiff
path: root/examples/hello.halk
diff options
context:
space:
mode:
authorc+12023-05-10 08:17:05 -0400
committerc+12023-05-10 08:17:05 -0400
commit5b303a0c3262a207b35d255ff52ce524f6e03d4c (patch)
tree011d7d2e45b3bb7856d26de7595a478cc891c476 /examples/hello.halk
parent8dd1bf3637c0d01816bbd48b28c02e9791243d35 (diff)
hello, halk
Diffstat (limited to 'examples/hello.halk')
-rw-r--r--examples/hello.halk24
1 files changed, 20 insertions, 4 deletions
diff --git a/examples/hello.halk b/examples/hello.halk
index cfa07f7..6f87160 100644
--- a/examples/hello.halk
+++ b/examples/hello.halk
@@ -5,10 +5,26 @@
#INCLUDE 'io' AS ''; [bring everything in 'io' into global scope]
+let.hello -> 'hello, '; [variables must be given a value at declaration]
-let. hello => 'hello, '; [variables must be given a value at declaration]
+let.PI => math/PI; [header namespaces are accessed with a '/']
[constants are denoted with a '=>']
-let. say_hello.to -> {
- let.greeting ->
-}
+fn.greeting.to -> { ['fn' only expects 1 argument, so no grouping of arguments is necessary]
+ let.message -> str.cat.(hello,to); [parens can be used to make calls to multi-argument
+ functions more clear]
+
+ stdo.message; [since 'io' was brought into global scope, we
+ don't need to (and, in fact, cannot) prefix it
+ with a namespace]
+};
+
+fn.sum_all._ -> { [variadic functions are possible with the reserved '_' argument,
+ which is treated as an array]
+ return.foldl.+,0,_;
+};
+
+fn.main -> { [where our code will begin executing]
+ greeting.[comments can be placed *anywhere*]"world.";
+ exit.0; [exit with code 0]
+};