Browse Source

Add len() std function

github-actions
Garrit Franke 3 years ago
parent
commit
2fce143a31
  1. 10
      lib/stdio.sb

10
lib/stdio.sb

@ -7,4 +7,14 @@ fn print(msg) {
// Like print(), but with an extra newline ('\n') character
fn println(msg) {
print(msg + "\n")
}
// Prints the size of an array
fn len(arr) {
let c = 0
while arr[c] {
c = c + 1
}
return c
}
Loading…
Cancel
Save