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