guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

147/197: gurses: In paragraph-format avoid use of car and cdr.


From: Danny Milosavljevic
Subject: 147/197: gurses: In paragraph-format avoid use of car and cdr.
Date: Mon, 3 Jul 2017 20:37:16 -0400 (EDT)

dannym pushed a commit to branch wip-installer-2
in repository guix.

commit 24c0ee3c006a603797ce32a8411f7fd6e4ff73bc
Author: John Darrington <address@hidden>
Date:   Fri Jan 27 09:21:30 2017 +0100

    gurses: In paragraph-format avoid use of car and cdr.
    
    * gurses/stexi.scm (paragraph-format): Use match instead of car and cdr.
---
 gurses/stexi.scm | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/gurses/stexi.scm b/gurses/stexi.scm
index c054676..e85ed82 100644
--- a/gurses/stexi.scm
+++ b/gurses/stexi.scm
@@ -149,9 +149,10 @@ cdr is the remainder"
 (define (paragraph-format cs line-length)
   (let loop ((pr (line-split cs line-length))
             (acc '()))
-    (if (null? (cdr pr))
-       (cons (car pr) acc)
-       (loop (line-split (cdr pr) line-length) (cons (car pr) acc)))))
+    (match pr
+           ((only) (cons only acc))
+           ((first . rest)
+            (loop (line-split rest line-length) (cons first acc))))))
 
 (define (justify text line-length)
   (reverse (paragraph-format text line-length )))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]