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: Inter-operating with Java lists


Bhinderwala, Shoeb wrote:

I have a list of Java objects in a Java list (e.g. java.util.ArrayList).

I have a scheme function that takes a Scheme list as a parameter.

How do I pass my Java list to the scheme function?

I think the thing to do is to generalize the makeList method in gnu.lists.LList as below. You can then invoke this from Scheme: (gnu.lists.LList:makeList jlist)

  public static LList makeList (java.util.List vals)
  {
    java.util.Iterator e = vals.iterator();
    LList result = LList.Empty;
    Pair last = null;
    while (e.hasNext())
      {
        Pair pair = new Pair(e.next(), LList.Empty);
        if (last == null)
          result = pair;
        else
          last.cdr = pair;
        last = pair;
      }
    return result;
  }

There are some other changes also needed, which I expect I will
check into CVS tomorrow morning.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/



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