From 6063bd4826dcd224c45781698b22c94133f63dbe Mon Sep 17 00:00:00 2001 From: cynic Date: Wed, 12 Oct 2022 09:55:48 -0400 Subject: [PATCH] built in insert --- lib.py | 3 +++ lib/lists.klambda | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib.py b/lib.py index e4dfde1..528a11a 100644 --- a/lib.py +++ b/lib.py @@ -100,6 +100,9 @@ def execute(program): return ret elif ctx[0] == _ident("at"): return subs[2][int(subs[1][1])] + elif ctx[0] == _ident("insert"): + subs[3].insert(int(subs[1][1]), subs[2]) + return subs[3] elif ctx[0] in funcspace: #print(subs) prototype = funcspace[ctx[0]] diff --git a/lib/lists.klambda b/lib/lists.klambda index 16ab02f..124e24a 100644 --- a/lib/lists.klambda +++ b/lib/lists.klambda @@ -1,3 +1,6 @@ (defun length (miracle - "__builtins__" "len" ((id $1)))) \ No newline at end of file + "__builtins__" "len" ((id $1)))) + +(defun append + (insert (length $2) $1 $2))