aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdump.scm21
1 files changed, 21 insertions, 0 deletions
diff --git a/dump.scm b/dump.scm
index 1f0a262..9a8cc07 100755
--- a/dump.scm
+++ b/dump.scm
@@ -98,6 +98,27 @@
(string->symbol
(format #f "~s~a" field schema))))
+(define (string-split-substring str substr)
+ "Split the string @var{str} into a list of substrings delimited by the
+substring @var{substr}."
+
+ (define substrlen (string-length substr))
+ (define strlen (string-length str))
+
+ (define (loop index start)
+ (cond
+ ((>= start strlen) (list ""))
+ ((not index) (list (substring str start)))
+ (else
+ (cons (substring str start index)
+ (let ((new-start (+ index substrlen)))
+ (loop (string-contains str substr new-start)
+ new-start))))))
+
+ (cond
+ ((string-contains str substr) => (lambda (idx) (loop idx 0)))
+ (else (list str))))
+
(define (delete-substrings str . substrings)
"Delete SUBSTRINGS, a list of strings, from STR."
(fold (lambda (substring result)