From 49bacbffde1b1c2cb8ed0906d04fa8184b2f623f Mon Sep 17 00:00:00 2001 From: redxef Date: Mon, 20 Jan 2025 20:52:11 +0100 Subject: [PATCH] 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. --- Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs b/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs index 340cde0..d16f46d 100644 --- a/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs +++ b/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs @@ -62,6 +62,18 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp { (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( """ (lambda