Guest User

Untitled

a guest
Nov 28th, 2019
112
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (define (string-find-char str char start)
  2.   (let ((end (string-length str)))  
  3.     (cond      
  4.       ((= start end) #f)
  5.       ((char=? (string-ref str start) char) start)
  6.       (else (string-find-char str char (+ start 1))))))
  7.  
  8. (define (%string-split str sep found-sep? start res)
  9.   (let ((next (string-find-char str sep start))  
  10.         (end (string-length str)))
  11.     (cond
  12.       (next (%string-split str sep #t (+ next 1) (cons (substring str start next) res)))
  13.       (found-sep? (%string-split str sep #f end (cons (substring str start end) res)))    
  14.       (else res))))
  15.  
  16. (define (string-split str sep)
  17.   (reverse (%string-split str sep #f 0 '())))
RAW Paste Data