From 2fce143a31c5d67a1e7da27819676f10280fdb0f Mon Sep 17 00:00:00 2001 From: Garrit Franke Date: Thu, 10 Dec 2020 22:13:44 +0100 Subject: [PATCH] Add len() std function --- lib/stdio.sb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/stdio.sb b/lib/stdio.sb index 34b0b7a..966a8b8 100644 --- a/lib/stdio.sb +++ b/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 } \ No newline at end of file