aboutsummaryrefslogtreecommitdiff
path: root/examples/hello.halk
blob: d046d1934b8477a4bd8a67270c7195986f4bfd0f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
` 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: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 ` 
                      n,
                      +. fib.(-. n, 1), fib. -. n, 2);