set array printer

This commit is contained in:
Yuichi Nishiwaki 2014-08-06 17:00:32 +09:00
parent 7de95e2817
commit 0eecddb5da
1 changed files with 17 additions and 1 deletions

View File

@ -1,5 +1,7 @@
(define-library (picrin array)
(import (scheme base))
(import (scheme base)
(scheme write)
(picrin record))
(define-record-type <array>
(create-array data size head tail)
@ -87,6 +89,20 @@
(define (array-for-each proc ary)
(for-each proc (array->list ary)))
(define (print-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)
(export make-array
array
array?