* update guile-stats functions a bit

This commit is contained in:
Dirk-Jan C. Binnema 2011-07-16 19:46:52 +03:00
parent 6c62a066c8
commit 59645ba268
1 changed files with 7 additions and 12 deletions

View File

@ -132,7 +132,7 @@ that match it."
(mu:stats:top-n
(lambda (msg) (mu:msg:subject msg)) N EXPR))
(define (mu:stats:table pairs)
(define* (mu:stats:table pairs #:optional (port (current-output-port)))
"display a list of PAIRS in a table-like fashion"
(let ((maxlen 0))
(for-each ;; find the widest in the first col
@ -144,17 +144,12 @@ that match it."
(let ((first (format #f "~s" (car pair)))
(second (format #f "~s" (cdr pair))))
(display (format #f "~A~v_~A\n"
first (- maxlen (string-length first)) second))))
first (- maxlen (string-length first)) second) port)))
pairs)))
(define (mu:stats:plot pairs)
"plot a table using gnuplot"
;; create a tmpfile with the data...
(define (mu:stats:export pairs)
"export pairs to a temporary file, return its name"
(let* ((datafile (tmpnam))
(output (open datafile (logior O_CREAT O_WRONLY) #O0644)))
(for-each
(lambda (pair) (display (format #f "~A ~A\n" (car pair) (cdr pair)) output))
pairs)
(close-output-port output)
;; now, display it.
(system (format #f "gnuplot -p -e 'plot \"~A\" w boxes fs pattern 2'" datafile))))
(mu:stats:table pairs output)
datafile))