Compare commits

..

2 commits

Author SHA1 Message Date
fef10b5736
feat: add length function. 2025-01-20 20:59:47 +01:00
49bacbffde
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.
2025-01-20 20:52:11 +01:00

View file

@ -62,6 +62,25 @@ 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["length"] = e.eval(
"""
(lambda
(lst n)
(if (null lst) n (length (cdr lst) (+ n 1))))
"""
);
this["qsort"] = e.eval( this["qsort"] = e.eval(
""" """
(lambda (lambda