[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
145/197: gurses: Avoid yet another use of car and cdr.
From: |
Danny Milosavljevic |
Subject: |
145/197: gurses: Avoid yet another use of car and cdr. |
Date: |
Mon, 3 Jul 2017 20:37:15 -0400 (EDT) |
dannym pushed a commit to branch wip-installer-2
in repository guix.
commit 9eba1ebbd6a3cdfcc1bb494212f7290aeea2cf56
Author: John Darrington <address@hidden>
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))))))))))
- 100/197: installer: Do not perform tasks more than once., (continued)
- 100/197: installer: Do not perform tasks more than once., Danny Milosavljevic, 2017/07/03
- 106/197: installer: Properly handle swap partitions when generating the configuration., Danny Milosavljevic, 2017/07/03
- 114/197: installer: Check that swap spaces have not been assigned mount points, Danny Milosavljevic, 2017/07/03
- 112/197: gurses: form: Use match instead of car, cdr etc., Danny Milosavljevic, 2017/07/03
- 125/197: installer: Do not assume the root file system is of type "ext4"., Danny Milosavljevic, 2017/07/03
- 130/197: installer: Delete unused procedure "justify"., Danny Milosavljevic, 2017/07/03
- 134/197: installer: Tolerate an undefined system role in config generation., Danny Milosavljevic, 2017/07/03
- 137/197: installer: Prepare for new wireless network features., Danny Milosavljevic, 2017/07/03
- 140/197: installer: Fix the key map option., Danny Milosavljevic, 2017/07/03
- 132/197: installer: Add new procedure to check file system specifications., Danny Milosavljevic, 2017/07/03
- 145/197: gurses: Avoid yet another use of car and cdr.,
Danny Milosavljevic <=
- 129/197: installer: Emphasise that writing filesystems destroys existing data., Danny Milosavljevic, 2017/07/03
- 150/197: gurses: Reimplement pad-complex-string., Danny Milosavljevic, 2017/07/03
- 159/197: installer: Fix i18n in dialogs., Danny Milosavljevic, 2017/07/03
- 154/197: installer: Main page: Redisplay translatable strings upon refresh., Danny Milosavljevic, 2017/07/03
- 157/197: installer: Replace 'file-browser' with 'key-map'., Danny Milosavljevic, 2017/07/03
- 161/197: installer: Improve i18n in ping page., Danny Milosavljevic, 2017/07/03
- 162/197: gurses: Avoid one use of car/cdr., Danny Milosavljevic, 2017/07/03
- 166/197: installer: Provide verbose description of locale., Danny Milosavljevic, 2017/07/03
- 167/197: installer: Fix bug when changing languages., Danny Milosavljevic, 2017/07/03
- 156/197: installer: New page to select language., Danny Milosavljevic, 2017/07/03