* array vs. bytevector
@ 2011-09-15 14:45 Johan Hidding
2011-09-15 15:08 ` Ludovic Courtès
0 siblings, 1 reply; 3+ messages in thread
From: Johan Hidding @ 2011-09-15 14:45 UTC (permalink / raw)
To: guile-user
Hi,
I was playing around with guile arrays, saving and restoring them from
disk. There are nice method called
(uniform-array-read! ...) and (uniform-array-write ...), however these
are depricated in favour of bytevector i/o. What is the prefered
method to interpret the data as an array? There is
(bytevector-ieee-double-ref ...) but that is quite cumbersome
especially when dealing with multidimensional complex arrays; then I
could use (c64vector-ref ...), but this interface is not as versatile
as with arrays. It would be simplest if (put-bytevector ...) would
accept an array as argument, but this gives a type-error (at least in
guile-2.0.2)
Any help would be greatly appreciated.
Cheers, Johan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: array vs. bytevector
2011-09-15 14:45 array vs. bytevector Johan Hidding
@ 2011-09-15 15:08 ` Ludovic Courtès
2011-09-15 16:19 ` Johan Hidding
0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2011-09-15 15:08 UTC (permalink / raw)
To: guile-user
Hi,
Johan Hidding <johannes.hidding@gmail.com> skribis:
> It would be simplest if (put-bytevector ...) would
> accept an array as argument, but this gives a type-error
It actually works with SRFI-4 vectors (info "(guile) SRFI-4 and
Bytevectors"):
scheme@(guile-user)> (use-modules(rnrs io ports))
scheme@(guile-user)> (put-bytevector (%make-void-port "w") #u8(1 2 3))
Does it help?
Ludo’.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: array vs. bytevector
2011-09-15 15:08 ` Ludovic Courtès
@ 2011-09-15 16:19 ` Johan Hidding
0 siblings, 0 replies; 3+ messages in thread
From: Johan Hidding @ 2011-09-15 16:19 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guile-user
Hi,
I think I found the answer in that I should use (array-contents ...) as such:
(import (rnrs io ports))
(put-bytevector (%make-void-port "w") (array-contents #2f64((1 2) (3 4))))
Cheers, Johan
2011/9/15 Ludovic Courtès <ludo@gnu.org>:
> Hi,
>
> Johan Hidding <johannes.hidding@gmail.com> skribis:
>
>> It would be simplest if (put-bytevector ...) would
>> accept an array as argument, but this gives a type-error
>
> It actually works with SRFI-4 vectors (info "(guile) SRFI-4 and
> Bytevectors"):
>
> scheme@(guile-user)> (use-modules(rnrs io ports))
> scheme@(guile-user)> (put-bytevector (%make-void-port "w") #u8(1 2 3))
>
> Does it help?
>
> Ludo’.
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-09-15 16:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-15 14:45 array vs. bytevector Johan Hidding
2011-09-15 15:08 ` Ludovic Courtès
2011-09-15 16:19 ` Johan Hidding
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).