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"
'(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 '()
(lambda (current accumulator)
@ -129,13 +129,10 @@
((compose (list
(coalesce-not-empty (lambda () (f (cdr values))))
flat
(filter id)
(map
(lambda (token)
((truthy-chaining (compose (list
(map (prepend (car token)))
(lambda (rest) (f (next rest values))))))
(starts-with (cdr token) values))))))
(map (lambda (token) ((compose (list
(map (prepend (car token)))
(lambda (rest) (if rest (f (next rest values)) '()))))
(starts-with (cdr token) values))))))
tokens))))))
(define (tokenize tokens)

Loading…
Cancel
Save