From 179c4b35057643c43ea3ca1e817593ce66f1ba98 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sat, 16 Dec 2023 13:51:18 +0100 Subject: [PATCH] restore list --- std/list.nil | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/std/list.nil b/std/list.nil index b404871..d7e0184 100644 --- a/std/list.nil +++ b/std/list.nil @@ -1,21 +1,21 @@ -//type List[T] = struct { -// ptr: Int, -// len: Int, -// cap: Int, -//}; -// -//function new(): List[Int] = ( -// List { ptr: 0, len: 0, cap: 0 } -//); -// -//function push(list: List[Int], elem: Int) = ( -// growIfNeeded(list, 1); -//); -// +type List[T] = struct { + ptr: Int, + len: Int, + cap: Int, +}; + +function new(): List[Int] = ( + List { ptr: 0, len: 0, cap: 0 } +); + +function push(list: List[Int], elem: Int) = ( + growIfNeeded(list, 1); +); + // PRIVATE: -// -//function growIfNeeded(list: List[Int], elems: Int) = ( -// if (list.len + elems) < list.cap then ( -// let newMemory = std.rt.alloc.allocateItem(0_I32, 0_I32); -// ); -//); + +function growIfNeeded(list: List[Int], elems: Int) = ( + if (list.len + elems) < list.cap then ( + let newMemory = std.rt.alloc.allocateItem(0_I32, 0_I32); + ); +);