aboutsummaryrefslogtreecommitdiff
path: root/lib.functions.lisp
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2025-02-10 07:25:43 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2025-02-11 00:40:19 +0000
commit279437cb81478bc5807674d15120fb38f7ebc3c3 (patch)
tree90a1299379b98428c18a46a04f2d088b18847179 /lib.functions.lisp
parent2d49ed25acc03550036b124e2ffade0edf812150 (diff)
downloadcantedraw-279437cb81478bc5807674d15120fb38f7ebc3c3.tar.gz
cantedraw-279437cb81478bc5807674d15120fb38f7ebc3c3.tar.bz2
cantedraw-279437cb81478bc5807674d15120fb38f7ebc3c3.zip
Implement `split` function.
Given a list and index into that list, return a cons where the car is all elements up to that index (exclusive) and the cdr is the rest of the list.
Diffstat (limited to 'lib.functions.lisp')
-rw-r--r--lib.functions.lisp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib.functions.lisp b/lib.functions.lisp
index 30c1e64..8eb2304 100644
--- a/lib.functions.lisp
+++ b/lib.functions.lisp
@@ -32,3 +32,7 @@ each member is STEP distance apart."
(fn take (n lst) (-> (fixnum list) list)
(subseq lst 0 n))
+
+(fn split (n lst) (-> (fixnum list) list)
+ (cons (take n lst)
+ (subseq lst n)))