albireo/test/simple/main.air
2024-03-29 16:20:34 +07:00

61 lines
1.2 KiB
Plaintext

; declare a module
module main
; no explicit export so everything in this module is exported
export one, two
; no import
import a
import a only name, name
import a as change_name
; declare a variable
one : number = 1
; declare a variable that is computed
; places a burden on the runtime
two : number = one + 1
; tt : bool = true
; types can be named, alias
; using tuple or record or enum
type coordinates_tuple = tuple (number, number)
; type coordinates_record = record { x : number , y : number }
coordinates_as_tuple : coordinates_tuple = tuple (1, 2)
; coordinates_as_record : coordinates_record = record { x : 1 , y : 2 }
; function definition is structured the same
void : fn => number = function is
let x = 1 in
1
return_false : fn => bool = function is
false
increment : fn number => number = function x is
x + 1
is_even : fn number => bool = function x is
if x % 2 then true else false
; invoke a function by name
bruh : number = increment(one)
; invoke a lambda function
bruh1 : number = (function x is x)(1)
; invoke a calculation returns a function
bruh2 : fn bool => number = function cond is
(if cond then
function x is x + 1
else
function x is x + 2
)(0)
main : fn => number = function is
1