[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
20/21: gurses: Add new procedure "word-endings".
From: |
John Darrington |
Subject: |
20/21: gurses: Add new procedure "word-endings". |
Date: |
Sun, 29 Jan 2017 07:35:02 +0000 (UTC) |
jmd pushed a commit to branch wip-installer
in repository guix.
commit eee7d2c96e110a5394de942948ded130f692c795
Author: John Darrington <address@hidden>
Date: Fri Jan 27 22:04:55 2017 +0100
gurses: Add new procedure "word-endings".
* gurses/stexi.scm (word-endings): New procedure.
---
gurses/stexi.scm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/gurses/stexi.scm b/gurses/stexi.scm
index e85ed82..87a7572 100644
--- a/gurses/stexi.scm
+++ b/gurses/stexi.scm
@@ -158,6 +158,33 @@ cdr is the remainder"
(reverse (paragraph-format text line-length )))
+(define-public (word-endings str)
+ "Return a list of all the indicies of all the word endings in STR. The list
is sorted in order of prefered padding location."
+ (let loop ((in str)
+ (x 0)
+ (n '())
+ (prev-white #t)
+ (prev-char #f)
+ )
+ (match
+ in
+ (() (map-in-order
+ (lambda (x) (car x))
+ (sort n (lambda (x y)
+ (if (eqv? (cadr x) (cadr y))
+ (> (caddr x) (caddr y))
+ (> (cadr x) (cadr y)))))))
+ ((first . rest)
+ (let ((white (xchar-blank? first)))
+ (loop rest (1+ x) (if (and (not prev-white) white)
+ (cons (list x
+ (case (xchar->char prev-char)
+ ((#\.) 3)
+ ((#\,) 2)
+ (else 1))
+ (random 1.0)) n)
+ n) white first))))))
+
(define (pad-complex-string str len)
"Return a complex string based on STR but with interword padding to make the
string of length LEN"
- branch wip-installer updated (61c0ffb -> 9ff399e), John Darrington, 2017/01/29
- 02/21: gurses: Use inverse instead of underline for field value area., John Darrington, 2017/01/29
- 07/21: installer: No passphrase is needed for clear networks., John Darrington, 2017/01/29
- 04/21: installer: Change livery., John Darrington, 2017/01/29
- 08/21: installer: Prepare for new wireless network features., John Darrington, 2017/01/29
- 05/21: installer: Tolerate an undefined system role in config generation., John Darrington, 2017/01/29
- 09/21: installer: Clear the mount point field for swap file systems., John Darrington, 2017/01/29
- 03/21: installer: Add new procedure to check file system specifications., John Darrington, 2017/01/29
- 01/21: installer: Delete unused procedure "justify"., John Darrington, 2017/01/29
- 20/21: gurses: Add new procedure "word-endings".,
John Darrington <=
- 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