Skip to content

Instantly share code, notes, and snippets.

@nekoTheShadow
Created October 25, 2015 11:43
Show Gist options
  • Save nekoTheShadow/7e20e690969708b16d13 to your computer and use it in GitHub Desktop.
Save nekoTheShadow/7e20e690969708b16d13 to your computer and use it in GitHub Desktop.
(use srfi-14)
(define (string-split string char-set-delimiter)
(let loop((str (string->list string)) (unit '()) (result '()))
(if (null? str)
(reverse (map (lambda (ls) (list->string (reverse ls))) (cons unit result)))
(if (char-set-contains? char-set-delimiter (car str))
(loop (cdr str) '() (cons unit result))
(loop (cdr str) (cons (car str) unit) result)))))
(write (string-split "1234/abc\nあいう" (string->char-set "/\n")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment