aboutsummaryrefslogtreecommitdiff
path: root/examples/hello.halk
blob: 4eeeeb7e4f5618a378b0183356729cfa85adbdfd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
` Comments in backticks. `

: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 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!". `