/usr/lib/s9fes/string-split.scm is in scheme9 2010.11.13-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ; Scheme 9 from Empty Space, Function Library
; By Nils M Holm, 2009,2010
; See the LICENSE file of the S9fES package for terms of use
;
; (string-split char string) ==> list
;
; Split a string into substrings. CHAR is interpreted as a separator.
; Return a list containing all coherent sequences of non-separating
; characters contained in the given string. When multiple subsequent
; separators are found, empty strings will be generated.
;
; Example: (string-split #\: "a::b:c:") ==> ("a" "" "b" "c" "")
(define (string-split c s)
(letrec
((split
(lambda (i k tmp res)
(cond ((= i k)
(cons tmp res))
((char=? (string-ref s i) c)
(split (+ 1 i)
k
""
(cons tmp res)))
(else
(split (+ 1 i)
k
(string-append
tmp
(string (string-ref s i)))
res))))))
(let ((k (string-length s)))
(reverse! (split 0 k "" '())))))
|