simplified tokenize

main
Inga 🏳‍🌈 12 months ago
parent b0a3de96b4
commit 6fcf46ec3f
  1. 13
      day01-hard/main.scm

@ -55,7 +55,7 @@
(assert-eq "flat test 1 failed" (assert-eq "flat test 1 failed"
'(1 2 3 4 5 (6 7) 8) '(1 2 3 4 5 (6 7) 8)
(flat '((1 2) (3 4) (5 (6 7) 8)))) (flat '((1 2) () (3 4) (5 (6 7) 8))))
(define (filter predicate) (reduce-right '() (define (filter predicate) (reduce-right '()
(lambda (current accumulator) (lambda (current accumulator)
@ -129,13 +129,10 @@
((compose (list ((compose (list
(coalesce-not-empty (lambda () (f (cdr values)))) (coalesce-not-empty (lambda () (f (cdr values))))
flat flat
(filter id) (map (lambda (token) ((compose (list
(map (map (prepend (car token)))
(lambda (token) (lambda (rest) (if rest (f (next rest values)) '()))))
((truthy-chaining (compose (list (starts-with (cdr token) values))))))
(map (prepend (car token)))
(lambda (rest) (f (next rest values))))))
(starts-with (cdr token) values))))))
tokens)))))) tokens))))))
(define (tokenize tokens) (define (tokenize tokens)

Loading…
Cancel
Save