summaryrefslogtreecommitdiff
path: root/guile
diff options
context:
space:
mode:
authordjcb <djcb@djcbsoftware.nl>2014-06-02 08:36:56 +0300
committerdjcb <djcb@djcbsoftware.nl>2014-06-02 08:36:56 +0300
commite954cb127bc0707c3558da81a86aa66e40c44105 (patch)
tree17d6afb4681f194f92ae9c22c8fd4add61b77cd8 /guile
parent2575e6b0a8da8c9c7e77cf2812862d99957dec82 (diff)
* mu-guile: add example
Diffstat (limited to 'guile')
-rw-r--r--guile/mu-guile.texi25
1 files changed, 25 insertions, 0 deletions
diff --git a/guile/mu-guile.texi b/guile/mu-guile.texi
index 7aff20f..b9b899e 100644
--- a/guile/mu-guile.texi
+++ b/guile/mu-guile.texi
@@ -84,6 +84,7 @@ Trust me, it's not very hard -- and it it's @emph{fun}!
Appendices
+* Recipies:: Snippets do specific things
* GNU Free Documentation License:: The license of this manual.
@end menu
@@ -957,6 +958,30 @@ $ mu msgs-per-month --textonly --query=hello
Please refer to the @t{mu-script} man-page for some details on writing your
own scripts.
+
+@node Recipies
+@appendix Recipies
+
+@itemize
+@item Calculating the average length of subject-lines
+@lisp
+;; the average length of all our
+(let ((len 0) (n 0))
+ (mu:for-each-message
+ (lambda (msg)
+ (set! len (+ len (string-length (or (mu:subject msg) ""))))
+ (set! n (+ n 1))))
+ (if (= n 0) 0 (/ len n)))
+ ;; this gives a rational, exact result;
+ ;; use exact->inexact to get decimals
+
+;; we we can make this short with the mu:average (with (mu stats))
+(mu:average (lambda (msg) (string-length (or (mu:subject msg) ""))))
+
+
+@end lisp
+@end itemize
+
@node GNU Free Documentation License
@appendix GNU Free Documentation License