This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: LList makeList
- From: Chris Dean <ctdean at sokitomi dot com>
- To: Mark Wutka <mark at wutka dot com>
- Cc: kawa at sources dot redhat dot com
- Date: Tue, 08 Mar 2005 22:41:08 -0800
- Subject: Re: LList makeList
- References: <20050308223114.GA31086@wutka.com>
> I was wondering what kind of support Kawa had for Java collections and
> saw the messages about using gnu.lists.LList:makeList to convert a Java
> list into a Scheme list.
There are many ways to do this. The simplest Scheme functions I use
are:
(define (iterator->list iter)
(let loop ((acc '()))
(if (java.util.Iterator:hasNext iter)
(loop (cons (java.util.Iterator:next iter) acc))
(reverse! acc))))
(define (collection->list coll)
(iterator->list (java.util.Collection:iterator coll)))
But it "real code" I'll just use a function that maps over collection
directly rather than convert it to a list and then call the R5RS map.
I can send you hash-table-map etc. if you send me a private email.
Regards,
Chris Dean