summaryrefslogtreecommitdiff
path: root/bs/string.scm
diff options
context:
space:
mode:
Diffstat (limited to 'bs/string.scm')
-rw-r--r--bs/string.scm45
1 files changed, 24 insertions, 21 deletions
diff --git a/bs/string.scm b/bs/string.scm
index 58f86a0..b1ad256 100644
--- a/bs/string.scm
+++ b/bs/string.scm
@@ -1,45 +1,45 @@
-(library (bs string (0))
+(library (bs string)
(export
replace replace-char to-string str capitalize split
- strip lstrip rstrip prefix? suffix?)
+ strip lstrip rstrip prefix? suffix? drop)
(import
- (rnrs base)
- (only (rnrs control) case-lambda)
- (only (rnrs io simple) display)
- (only (srfi srfi-13)
- string-trim string-trim-both string-trim-right
- string-prefix? string-suffix? string-upcase string-concatenate
- string-drop string-take string-contains substring/shared string-null? string-fold
- string-tokenize)
- (only (srfi srfi-14)
- string->char-set char-set-complement char-set)
- (only (srfi srfi-28) format)
- ;; TODO: port ice-9 dependency or replace with (scheme something)
- (only (ice-9 ports) with-output-to-string))
+ (rnrs base)
+ (only (rnrs control) case-lambda)
+ (only (rnrs io simple) display)
+ (only (srfi srfi-13)
+ string-trim string-trim-both string-trim-right
+ string-prefix? string-suffix? string-upcase string-concatenate
+ string-drop string-take string-contains substring/shared string-null? string-fold
+ string-tokenize)
+ (only (srfi srfi-14)
+ string->char-set char-set-complement char-set)
+ (only (srfi srfi-28) format)
+ ;; TODO: port ice-9 dependency or replace with (scheme something)
+ (only (ice-9 ports) with-output-to-string))
(define (prefix? s pre)
- "Is PRE a prefix of S?"
+ #;"Is PRE a prefix of S?"
(string-prefix? pre s))
(define (suffix? s suf)
- "Is SUF a suffix of S?"
+ #;"Is SUF a suffix of S?"
(string-suffix? suf s))
(define (split s sep)
- "Split S at SEP"
+ #;"Split S at SEP"
;; this is still wrong. it splits on any of the "sep" characters
;; instead of all of them
(string-tokenize s (char-set-complement (apply char-set (string->list sep)))))
(define (replace-char s match char)
- "Replace MATCH in S with CHAR"
+ #;"Replace MATCH in S with CHAR"
(let ((f (lambda (a b)
(let ((next-char (if (eq? a match) char a)))
(string-concatenate (list b (string next-char)))))))
(string-fold f "" s)))
(define (replace s match repl)
- "Replace MATCH in S with REPL"
+ #;"Replace MATCH in S with REPL"
;; based on string-replace-substring By A. Wingo in
;; https://lists.gnu.org/archive/html/guile-devel/2014-03/msg00058.html
;; also in string-replace-substring guix:guix/utils.scm.
@@ -79,4 +79,7 @@
(string-trim s char))
(define (rstrip s char)
- (string-trim-right s char )))
+ (string-trim-right s char))
+
+ (define (drop s num)
+ (string-drop s num)))