From 6425e62a20d79fc6fe7876de49479087ffce8b52 Mon Sep 17 00:00:00 2001 From: SouthFox Date: Fri, 1 Nov 2024 13:59:40 +0800 Subject: [PATCH] feat: add find-string-list-len Signed-off-by: SouthFox --- game.scm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/game.scm b/game.scm index e1e7c8d..cd34846 100644 --- a/game.scm +++ b/game.scm @@ -165,7 +165,7 @@ )) `(pre ,(string-join ink-script "\n"))) - +;; Lib (define (sub-string-list string-list start len) (define (sub-string-list-iter string-list start len part) (if (string? (car string-list)) @@ -189,6 +189,15 @@ (append part (list (car string-list)))))) (sub-string-list-iter string-list start len '())) +(define (find-string-list-len string-list) + (define (find-string-list-len-iter string-list offset) + (if (string? (car string-list)) + (if (string-index (car string-list) #\newline) + (+ (string-index (car string-list) #\newline) offset) + (find-string-list-len-iter (cdr string-list) (+ (string-length (car string-list)) offset))) + (find-string-list-len-iter (cdr string-list) (+ (string-length (car (last-pair (car string-list)))) offset) ))) + (find-string-list-len-iter string-list 0)) + ;; Main (set! *template* template-task)