From 6f860bbb29c263e3436e97a0d60c83ca8ca1518a Mon Sep 17 00:00:00 2001 From: SouthFox Date: Sun, 3 Nov 2024 00:15:47 +0800 Subject: [PATCH] feat: add func apply for sub-string-list --- game.scm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/game.scm b/game.scm index df4b9bd..a8ae63a 100644 --- a/game.scm +++ b/game.scm @@ -166,15 +166,15 @@ `(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) +(define (sub-string-list string-list start len func) + (define (sub-string-list-iter string-list start len func part) (if (string? (car string-list)) (if (> (string-length (car string-list)) start) (append part (if (= start 0 ) '() (substring (car string-list) 0 start)) - (list (substring (car string-list) start (+ start len))) + (list (func (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))))) @@ -182,12 +182,14 @@ (sub-string-list-iter (cdr string-list) (- start (string-length (car string-list))) len + func (append part (list (car string-list))))) (sub-string-list-iter (cdr string-list) (- start (string-length (car (last-pair (car string-list))))) len + func (append part (list (car string-list)))))) - (sub-string-list-iter string-list start len '())) + (sub-string-list-iter string-list start len func '())) (define (find-string-list-len string-list) (define (find-string-list-len-iter string-list offset)