dannym pushed a commit to branch wip-installer-2
in repository guix.
commit 9eba1ebbd6a3cdfcc1bb494212f7290aeea2cf56
Author: John Darrington <[email protected]>
Date: Fri Jan 27 09:07:29 2017 +0100
gurses: Avoid yet another use of car and cdr.
* gurses/stexi.scm (pad-complex-string): Use match instead of car and cdr.
---
gurses/stexi.scm | 42 ++++++++++++++++++++++--------------------
1 file changed, 22 insertions(+), 20 deletions(-)
diff --git a/gurses/stexi.scm b/gurses/stexi.scm
index cb383e8..6a0a6a7 100644
--- a/gurses/stexi.scm
+++ b/gurses/stexi.scm
@@ -196,23 +196,25 @@ string of length LEN"
(words 0)
(spaces 0)
(prev-white #t))
- (if (null? in)
- (reverse out)
- (let* ((white (xchar-blank? (car in)))
- (end-of-word (and white (not prev-white)))
- (words-processed (if end-of-word (1+ words) words))
- (spaces-inserted (if end-of-word
- (truncate (- (*
- (/ underflow
inter-word-space-count)
- words-processed)
- spaces))
- 0)))
- (loop (cdr in)
- ;; FIXME: Use a more intelligent algorithm.
- ;; (prefer spaces at sentence endings for example)
- (append
- (make-list spaces-inserted (normal #\space))
- (cons (car in) out))
- words-processed
- (+ spaces spaces-inserted)
- white)))))))))
+ (match
+ in
+ (() (reverse out))
+ ((first . rest)
+ (let* ((white (xchar-blank? first))
+ (end-of-word (and white (not prev-white)))
+ (words-processed (if end-of-word (1+ words) words))
+ (spaces-inserted (if end-of-word
+ (truncate (- (*
+ (/ underflow
inter-word-space-count)
+ words-processed)
+ spaces))
+ 0)))
+ (loop rest
+ ;; FIXME: Use a more intelligent algorithm.
+ ;; (prefer spaces at sentence endings for example)
+ (append
+ (make-list spaces-inserted (normal #\space))
+ (cons first out))
+ words-processed
+ (+ spaces spaces-inserted)
+ white))))))))))