adventofcode

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

commit 3e57f1ebeb9076f92c91773218a3dd498a493840
parent c4bee13aa8bc81bad5b32c24e97114ae3067c690
Author: mpizzzle <m@michaelpercival.xyz>
Date:   Thu, 17 Dec 2020 13:33:33 +0000

missing tokenize function (there must a library function for this somewhere...)

Diffstat:
A2020/tokenize.scm | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/2020/tokenize.scm b/2020/tokenize.scm @@ -0,0 +1,7 @@ +(define (tokenize str chr) + (let ((in (memq chr (string->list str))) + (idx (lambda (s c) (- (string-length s) (length (memq c (string->list s))))))) + (if in + (cons (substring str 0 (idx str (car in))) + (tokenize (substring str (+ (idx str (car in)) 1) (string-length str)) chr)) + (cons str '()))))