[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
17/21: gurses: Use match instead of car/cdr in line-split.
From: |
John Darrington |
Subject: |
17/21: gurses: Use match instead of car/cdr in line-split. |
Date: |
Sun, 29 Jan 2017 07:35:02 +0000 (UTC) |
jmd pushed a commit to branch wip-installer
in repository guix.
commit 7c1a952bc5cea6484871b008be6e67034ff0412f
Author: John Darrington <address@hidden>
Date: Fri Jan 27 09:17:30 2017 +0100
gurses: Use match instead of car/cdr in line-split.
* gurses/stexi.scm (line-split): Replace car/cdr with match
---
gurses/stexi.scm | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/gurses/stexi.scm b/gurses/stexi.scm
index 6a0a6a7..c054676 100644
--- a/gurses/stexi.scm
+++ b/gurses/stexi.scm
@@ -131,20 +131,20 @@ described by the stexi STXI"
(define (line-split cs line-length)
"Return a pair whose car is the first LINE-LENGTH elements of cs and whose
-cdr is the rest"
+cdr is the remainder"
(let loop ((in cs)
(count 0)
(line0 '())
- (rest '()))
- (if (null? in)
- (let* ((trimmed-line (remove-leading-whitespace line0))
- (len (length trimmed-line)))
- (cons (reverse trimmed-line)
- (reverse rest)))
-
- (if (< (+ (offset-to-end-of-word in) count) line-length)
- (loop (cdr in) (1+ count) (cons (car in) line0) rest)
- (loop (cdr in) (1+ count) line0 (cons (car in) rest))))))
+ (remainder '()))
+ (match
+ in
+ (() (let ((trimmed-line (remove-leading-whitespace line0)))
+ (cons (reverse trimmed-line) (reverse remainder))))
+
+ ((first . rest)
+ (if (< (+ (offset-to-end-of-word in) count) line-length)
+ (loop rest (1+ count) (cons first line0) remainder)
+ (loop rest (1+ count) line0 (cons first remainder)))))))
(define (paragraph-format cs line-length)
(let loop ((pr (line-split cs line-length))
- 14/21: gurses: Add predicate to test if a complex char is blank., (continued)
- 14/21: gurses: Add predicate to test if a complex char is blank., John Darrington, 2017/01/29
- 12/21: gurses: Avoid one usage of car and cdr., John Darrington, 2017/01/29
- 15/21: gurses: Avoid one more use of car and cdr., John Darrington, 2017/01/29
- 13/21: gurses: xchar->char: New procedure., John Darrington, 2017/01/29
- 19/21: installer: Support WEP encrypted wireless., John Darrington, 2017/01/29
- 16/21: gurses: Avoid yet another use of car and cdr., John Darrington, 2017/01/29
- 11/21: installer: Fix the key map option., John Darrington, 2017/01/29
- 18/21: gurses: In paragraph-format avoid use of car and cdr., John Darrington, 2017/01/29
- 06/21: installer: Use a "hard" method of rebooting. Do not rely on shepherd., John Darrington, 2017/01/29
- 10/21: installer: Allow file system specifications to be removed., John Darrington, 2017/01/29
- 17/21: gurses: Use match instead of car/cdr in line-split.,
John Darrington <=
- 21/21: gurses: Reimplement pad-complex-string., John Darrington, 2017/01/29