diff --git a/gash/lexer.scm b/gash/lexer.scm index 4eaa2e2..bbafb89 100644 --- a/gash/lexer.scm +++ b/gash/lexer.scm @@ -165,13 +165,16 @@ (define (join-contiguous-strings lst) "Join all contiguous strings in @var{lst}." - (fold-right (lambda (x lst) - (let ((head (if (null? lst) #f (car lst)))) - (if (and (string? x) (string? head)) - (cons (string-append x head) (cdr lst)) - (cons x lst)))) - '() - lst)) + (match lst + (() lst) + ((head . rest) + (reverse + (fold (lambda (x acc) + (if (and (string? x) (string? (car acc))) + (cons (string-append (car acc) x) (cdr acc)) + (cons x acc))) + (list head) + rest))))) (define-inlinable (next-char port) "Advance @var{port} by one character and return the lookahead