lexer: Avoid 'fold-right'.
* gash/lexer.scm (join-contiguous-strings): Use 'fold' and 'reverse' instead of 'fold-right'.
This commit is contained in:
parent
cfb4da73d0
commit
864e51250b
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue