lloda pushed a commit to branch wip-exception-truncate in repository guile.
commit 7cf89a3460d0dfeb6e179ff2189cc3d8ed1e4239 Author: Daniel Llorens <[email protected]> Date: Thu Feb 16 18:40:36 2017 +0100 Explicit #:dims? option for array-print, array-print-prefix An array with all the dimensions printed out is still readable syntax and may be read faster. * module/ice-9/arrays.scm (array-print-prefix, array-print): As stated. --- module/ice-9/arrays.scm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/module/ice-9/arrays.scm b/module/ice-9/arrays.scm index 4850522..450dd3f 100644 --- a/module/ice-9/arrays.scm +++ b/module/ice-9/arrays.scm @@ -39,14 +39,14 @@ ;; Printing arrays ;; FIXME replace scm_i_print_array() when performance allows. -(define (array-print-prefix a port) +(define* (array-print-prefix a port #:key dims?) (put-char port #\#) (display (array-rank a) port) (let ((t (array-type a))) (unless (eq? #t t) (display t port))) (let ((ss (array-shape a))) - (let loop ((s ss) (slos? #f) (szero? #f) (slens? #f)) + (let loop ((s ss) (slos? #f) (szero? #f) (slens? dims?)) (define lo caar) (define hi cadar) (if (null? s) @@ -65,11 +65,11 @@ (or szero? zero-size?) (or slens? (and (not zero-size?) szero?)))))))) -(define (array-print a port) +(define* (array-print a port #:key dims?) (define (array-rest a s) (apply make-shared-array a (lambda i i) (cons (list (+ 1 (caar s)) (cadar s)) (cdr s)))) - (array-print-prefix a port) + (array-print-prefix a port #:dims? dims?) (let ((ss (array-shape a))) (cond ((zero? (array-rank a))
