guix-commits
[Top][All Lists]
Advanced

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

15/21: gurses: Avoid one more use of car and cdr.


From: John Darrington
Subject: 15/21: gurses: Avoid one more use of car and cdr.
Date: Sun, 29 Jan 2017 07:35:02 +0000 (UTC)

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

commit ffb989a53da3df25af38a089d5150d106eef4d66
Author: John Darrington <address@hidden>
Date:   Fri Jan 27 09:03:56 2017 +0100

    gurses: Avoid one more use of car and cdr.
    
    * gurses/stexi.scm (count-words): Use match instead of car and cdr.
---
 gurses/stexi.scm |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/gurses/stexi.scm b/gurses/stexi.scm
index 6174d73..cb383e8 100644
--- a/gurses/stexi.scm
+++ b/gurses/stexi.scm
@@ -166,12 +166,14 @@ string of length LEN"
               (x 0)
               (n 0)
               (prev-white #t))
-      (if (null? in)
-         n
-         (let ((white (xchar-blank? (car in))))
-            (loop (cdr in) (1+ x) (if (and prev-white (not white))
-                                      (1+ n)
-                                      n) white)))))
+      (match
+       in
+       (() n)
+       ((first . rest)
+        (let ((white (xchar-blank? first)))
+          (loop rest (1+ x) (if (and prev-white (not white))
+                                (1+ n)
+                                n) white))))))
 
   (let* ((underflow (- len (length str)))
         (word-count (count-words str))



reply via email to

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