summaryrefslogtreecommitdiff
path: root/code/basic.felan
blob: 9d93ef82283adb89e367b74ffd6187fd64852eca (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
string :: []u8;

print :: (value:[]u8)->void{
  i :u64= 0;
  while i < value.length {
    putc value[i];
    i += 1;
  }
};

print :: (value:u64)->void{
  value := value;
  result :[20]u8 = undefined;
  i := 0;
  while {
    result[i] = '0' + @cast(value % 10,u8);
    i += 1;
    value /= 10;
    value != 0;
  } {}

  j := 0;
  while j < i {
    putc result[j];
    j += 1;
  }
};

to_u64 :: (value:string) -> u64 {
  i := value.length;
  result :u64= 0;

  while i > 0 {
    c := value[i-1];
    result *= 10;
    result += @cast(c - '0',u64);
    i -= 1;
  }
  return result;
};