summaryrefslogtreecommitdiff
path: root/example.us
blob: 70da78f2a325f0ea963f62afe8a07efed5452ccc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Variables must be snake_case.
let hello_world = "Hello, world"

# Define a global variable, accessible anywhere. It is put on its own stack.
global hello_world = "Poggers"

let num = 5

if num % 2 == 0:
  log.info("fair")
else:
  log.info("strange")
end

loop:
  # infinite loop
  break
end

loop num > 0:
  # conditional loop
  if num == 4:
    num = 3
    next # equivalent to continue in other languages
  end
  num -= 1
end

let list = [1, 2, 5, 4]
loop i in list:
  # iterator loop
  log.info(i)
end

fun main:init()
end

fun sum(a, b)
  ret a + b

fun print_sum(a, b)
  let val = sum(a, b)
  log.info(val)
end

do:
        # Standalone scope
        let a = 1
        log.info(a)
end