From 4d41b1186f3dc721102cd1d9e47dde233f7b1e40 Mon Sep 17 00:00:00 2001 From: c Date: Tue, 5 Dec 2023 13:14:50 -0500 Subject: Updated examples. --- examples/hello.halk | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'examples/hello.halk') 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!". ` -- cgit v1.2.3