feat: implement split function.

Takes a list and an integer, splits off n elements from the list
and returns a list where the first element contains the first n
elements of the original list, the cdr of that list contains the
rest.
This commit is contained in:
redxef 2025-01-20 20:52:11 +01:00
parent 49298a3ca2
commit 49bacbffde
Signed by: redxef
GPG key ID: 7DAC3AA211CBD921

View file

@ -62,6 +62,18 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp {
(rev-helper lst '()))) (rev-helper lst '())))
""" """
); );
this["split"] = e.eval(
"""
(lambda
(lst n)
(if
(or (= n 0) (null lst))
(cons '() lst)
(let
(s (split (cdr lst) (- n 1)))
(cons (cons (car lst) (car s)) (cdr s)))))
"""
);
this["qsort"] = e.eval( this["qsort"] = e.eval(
""" """
(lambda (lambda