diff options
author | c | 2023-12-05 13:14:50 -0500 |
---|---|---|
committer | c | 2023-12-05 13:14:50 -0500 |
commit | 4d41b1186f3dc721102cd1d9e47dde233f7b1e40 (patch) | |
tree | e7a715570d3c13ba041cb08f722ed65d009ede5f /examples/hello.halk | |
parent | a75b474bf153388e39c31b072a4bf0d49190cc5b (diff) |
Updated examples.
Diffstat (limited to 'examples/hello.halk')
-rw-r--r-- | examples/hello.halk | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/examples/hello.halk b/examples/hello.halk index d046d19..0fb2fd6 100644 --- a/examples/hello.halk +++ b/examples/hello.halk @@ -1,18 +1,16 @@ -` comments in backticks ` +` Comments in backticks. ` -#inc# #somefile.halk# ` include a file ` -#inc# #stdio# ` include the 'stdio' header (file path stored in the macro #stdio#) ` +:str:hello = "Hello"; ` Define a variable "hello" with the type "str". ` -:str:hello = "Hello"; ` define a variable 'hello' with the type 'str' ` - -:str:greet.:str:target = strcat.hello, ", ", target; ` define a function 'greet' that returns a 'str' and accepts an - argument 'target', also of type 'str' ` +:str:greet.:str:target = strcat.hello, ", ", target; ` Define a function "greet" that returns a "str" and accepts an + argument "target", also of type "str". ` ` some more functions ` :void:add1.:int:n+=. n, 1; :int:fac.:int:n=?.(=.n,0),1,*.n,fac.-.n,1; -:int:fib. :int:n = ?. (<=. n, 1), ` multiple lines can be used for clarity ` +:int:fib. :int:n = ?. (<=. n, 1), ` Multiple lines and whitespace can be used for clarity. ` n, +. fib.(-. n, 1), fib. -. n, 2); +io!print.greet."world!"; ` Use previously defined function to print "Hello, world!". ` |