diff options
Diffstat (limited to 'charplot.scm')
-rw-r--r-- | charplot.scm | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/charplot.scm b/charplot.scm index 890fca0..31d0fea 100644 --- a/charplot.scm +++ b/charplot.scm @@ -85,7 +85,7 @@ (output-port-height (current-output-port)))) (width (or (and charplot:dimensions (cadr charplot:dimensions)) (output-port-width (current-output-port))))) - (define pra (create-array " " height width)) + (define pra (make-array " " height width)) ;;Put newlines on right edge (do ((idx (+ -1 height) (+ -1 idx))) ((negative? idx)) @@ -166,20 +166,24 @@ (define (charplot:array->list ra) (define dims (array-dimensions ra)) - (do ((idx (+ -1 (car dims)) (+ -1 idx)) - (cols '() (cons (do ((jdx (+ -1 (cadr dims)) (+ -1 jdx)) - (row '() (cons (array-ref ra idx jdx) row))) - ((negative? jdx) row)) - cols))) - ((negative? idx) cols))) + (if (= 2 (length dims)) + (do ((idx (+ -1 (car dims)) (+ -1 idx)) + (cols '() (cons (do ((jdx (+ -1 (cadr dims)) (+ -1 jdx)) + (row '() (cons (array-ref ra idx jdx) row))) + ((negative? jdx) row)) + cols))) + ((negative? idx) cols)) + (do ((idx (+ -1 (car dims)) (+ -1 idx)) + (cols '() (cons (array-ref ra idx) cols))) + ((negative? idx) cols)))) ;;;Converts data to list of coordinates (list). (define (charplot:data->lists data) (cond ((array? data) (case (array-rank data) ((1) (set! data (map list - (let ((ra (apply create-array '#() - (array-shape data)))) + (let ((ra (apply make-array '#() + (array-dimensions data)))) (array-index-map! ra identity) (charplot:array->list ra)) (charplot:array->list data)))) @@ -279,12 +283,13 @@ data) (array-for-each write-char pra) (if (not (eqv? #\newline (apply array-ref pra - (map cadr (array-shape pra))))) + (map (lambda (x) (+ -1 x)) + (array-dimensions pra))))) (newline)))) (define (charplot:plot-function func vlo vhi . npts) (set! npts (if (null? npts) 64 (car npts))) - (let ((dats (create-array (Ar64) npts 2))) + (let ((dats (make-array (A:floR64b) npts 2))) (array-index-map! (make-shared-array dats (lambda (idx) (list idx 0)) npts) (lambda (idx) (+ vlo (* (- vhi vlo) (/ idx (+ -1 npts)))))) |