adventofcode

https://adventofcode.com/
Log | Files | Refs

tokenize.scm (330B)


      1 (define (tokenize str chr)
      2   (let ((in (memq chr (string->list str)))
      3         (idx (lambda (s c) (- (string-length s) (length (memq c (string->list s)))))))
      4     (if in
      5       (cons (substring str 0 (idx str (car in)))
      6             (tokenize (substring str (+ (idx str (car in)) 1) (string-length str)) chr))
      7       (cons str '()))))