use define-record-writer to set custom writer to <array> type
This commit is contained in:
parent
75138db4db
commit
fff22f253f
piclib/picrin
|
@ -89,19 +89,17 @@
|
||||||
(define (array-for-each proc ary)
|
(define (array-for-each proc ary)
|
||||||
(for-each proc (array->list ary)))
|
(for-each proc (array->list ary)))
|
||||||
|
|
||||||
(define (print-array array)
|
(define-record-writer (<array> array)
|
||||||
(call-with-port (open-output-string)
|
(call-with-port (open-output-string)
|
||||||
(lambda (port)
|
(lambda (port)
|
||||||
(display "#.(array" port)
|
(display "#.(array" port)
|
||||||
(array-for-each
|
(array-for-each
|
||||||
(lambda (obj)
|
(lambda (obj)
|
||||||
(display " " port)
|
(display " " port)
|
||||||
(write obj port))
|
(write obj port))
|
||||||
array)
|
array)
|
||||||
(display ")" port)
|
(display ")" port)
|
||||||
(get-output-string port))))
|
(get-output-string port))))
|
||||||
|
|
||||||
(record-set! <array> 'writer print-array)
|
|
||||||
|
|
||||||
(export make-array
|
(export make-array
|
||||||
array
|
array
|
||||||
|
|
Loading…
Reference in New Issue