From e954cb127bc0707c3558da81a86aa66e40c44105 Mon Sep 17 00:00:00 2001 From: djcb Date: Mon, 2 Jun 2014 08:36:56 +0300 Subject: [PATCH] * mu-guile: add example --- guile/mu-guile.texi | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/guile/mu-guile.texi b/guile/mu-guile.texi index 7aff20f5..b9b899e6 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