# HG changeset patch # User Steve Losh # Date 1621803100 14400 # Node ID ec9067ea1894839c4389ad5188de8f5ea7398d3f # Parent 25d07c1574959fb3e024b9070f6c6f935150b67c Allow gnuplot to take alists diff -r 25d07c157495 -r ec9067ea1894 src/gnuplot.lisp --- a/src/gnuplot.lisp Sun May 23 16:43:03 2021 -0400 +++ b/src/gnuplot.lisp Sun May 23 16:51:40 2021 -0400 @@ -23,6 +23,13 @@ (terpri s)) sequence)) +(defun gnuplot-data-alist% (alist s) + (loop :for (k . v) :in alist :do + (princ k s) + (princ #\tab s) + (princ v s) + (terpri s))) + (defun gnuplot-data-matrix% (matrix s) (destructuring-bind (rows cols) (array-dimensions matrix) (dotimes (r rows) @@ -36,7 +43,8 @@ `identifier` must be a string of the form `$foo`. - `data` must be a sequence of sequences of data or a 2D array of data. + `data` must be one of the following: a sequence of sequences of data points, + an alist of data points, or a 2D array of data points. Must be called from inside `with-gnuplot`. @@ -47,6 +55,7 @@ (format s "~A << EOD~%" identifier) (etypecase data ((array * (* *)) (gnuplot-data-matrix% data s)) + ((cons (cons t (not cons))) (gnuplot-data-alist% data s)) (sequence (gnuplot-data-sequence% data s))) (format s "EOD~%")) @@ -72,9 +81,11 @@ (defun gnuplot (data commands) "Graph `data` with gnuplot using `commands`. - `data` must be an alist of `(identifier . data)` pairs. `identifier` must be - a string of the form `$foo`. `data` must be a sequence of sequences of data - or a 2D array of data. + `data` must be an alist of `(identifier . data)` pairs. + + Each `identifier` must be a string of the form `$foo`. Each `data` must be + one of the following: a sequence of sequences of data points, an alist of data + points, or a 2D array of data points. `commands` must be a string or a sequence of strings. @@ -86,3 +97,4 @@ (string (gnuplot-command commands)) (sequence (map nil #'gnuplot-command commands))))) + diff -r 25d07c157495 -r ec9067ea1894 src/iterate.lisp --- a/src/iterate.lisp Sun May 23 16:43:03 2021 -0400 +++ b/src/iterate.lisp Sun May 23 16:51:40 2021 -0400 @@ -727,7 +727,6 @@ (finally (return (get-output-stream-string ,sos))))))) - (defmacro-clause (ORING expr &optional INTO var) (let ((result (or var iterate::*result-var*))) `(reducing ,expr :by #'or :into ,result :initial-value nil)))