(import (except scheme string-length string-ref string-set! make-string string substring string->list list->string string-fill! write-char read-char display) (except chicken reverse-list->string print print*)) (require-extension matchable utf8 persistent-hash-map utf8-srfi-13 utils) (define source-text (let group-by-prefix ((words (string-tokenize (read-all "source"))) (hash-map (persistent-map))) (match words ((w o r . ds) (let ((key (string-append w " " o))) (group-by-prefix (cons o (cons r ds)) (map-add hash-map key (cons r (map-ref hash-map key '())))))) (_ hash-map))))