From 4e408e45d7a402f5258c122416b46812e3a66569 Mon Sep 17 00:00:00 2001 From: SouthFox Date: Thu, 31 Oct 2024 23:40:26 +0800 Subject: [PATCH] feat: add sub-string-list --- game.scm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/game.scm b/game.scm index 02dbfd3..8972373 100644 --- a/game.scm +++ b/game.scm @@ -166,6 +166,25 @@ `(pre ,(string-join ink-script "\n"))) +(define (sub-string-list string-list start len part) + (if (string? (car string-list)) + (if (> (string-length (car string-list)) start) + (append part + (list (substring (car string-list) 0 start) + (substring (car string-list) start (+ start len))) + (if (= (+ start len) (string-length (car string-list))) + '() + (list (substring (car string-list) (+ start len) (string-length (car string-list))))) + (cdr string-list)) + (sub-string-list (cdr string-list) + (- start (string-length (car string-list))) + len + (append part (list (car string-list))))) + (sub-string-list (cdr string-list) + (- start (string-length (car (last-pair (car string-list))))) + len + (append part (list (car string-list)))))) + ;; Main (set! *template* template-task)