This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: LList makeList


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]