[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
146/197: gurses: Use match instead of car/cdr in line-split.
From: |
Danny Milosavljevic |
Subject: |
146/197: gurses: Use match instead of car/cdr in line-split. |
Date: |
Mon, 3 Jul 2017 20:37:15 -0400 (EDT) |
dannym pushed a commit to branch wip-installer-2
in repository guix.
commit 8e31b8e452b06c1782a7a36ea9bad04ed106675e
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))
- 111/197: gurses: Change highlighting from bold to inverse., (continued)
- 111/197: gurses: Change highlighting from bold to inverse., Danny Milosavljevic, 2017/07/03
- 108/197: installer: Do not add file systems which are invalid., Danny Milosavljevic, 2017/07/03
- 164/197: gurses: Use match instead of car., Danny Milosavljevic, 2017/07/03
- 170/197: installer: Remove unused procedure., Danny Milosavljevic, 2017/07/03
- 152/197: installer: New file i18n.scm., Danny Milosavljevic, 2017/07/03
- 110/197: installer: Add an explanatory text to the main page., Danny Milosavljevic, 2017/07/03
- 120/197: gurses: Mini refactor., Danny Milosavljevic, 2017/07/03
- 124/197: gurses: Populate dropdown boxes in forms using a menu., Danny Milosavljevic, 2017/07/03
- 131/197: gurses: Use inverse instead of underline for field value area., Danny Milosavljevic, 2017/07/03
- 133/197: installer: Change livery., Danny Milosavljevic, 2017/07/03
- 146/197: gurses: Use match instead of car/cdr in line-split.,
Danny Milosavljevic <=
- 147/197: gurses: In paragraph-format avoid use of car and cdr., Danny Milosavljevic, 2017/07/03
- 144/197: gurses: Avoid one more use of car and cdr., Danny Milosavljevic, 2017/07/03
- 143/197: gurses: Add predicate to test if a complex char is blank., Danny Milosavljevic, 2017/07/03
- 149/197: gurses: Add new procedure "word-endings"., Danny Milosavljevic, 2017/07/03
- 155/197: installer: Use _ instead of M_ for host-name-refresh., Danny Milosavljevic, 2017/07/03
- 160/197: installer: New convenience procedures., Danny Milosavljevic, 2017/07/03
- 158/197: installer: Correct placement of gettext call., Danny Milosavljevic, 2017/07/03
- 163/197: gurses: Cache the windows of buttons., Danny Milosavljevic, 2017/07/03
- 172/197: gurses: Update the cursor position when posting the form., Danny Milosavljevic, 2017/07/03
- 165/197: installer: New procedure key-value-slurp., Danny Milosavljevic, 2017/07/03