dannym pushed a commit to branch wip-installer-2
in repository guix.
commit 8e31b8e452b06c1782a7a36ea9bad04ed106675e
Author: John Darrington <[email protected]>
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))