1

I wrote the following scheme function, which works as expected when called in Dr Racket, but only returns half of the result when called using kawa.

(define getYValues (lambda (f base lst)
              (if (null? lst) 
              base
              (cons (f (car lst)) (getYValues f base (cdr lst)))
              )
      )
)

The values used for testing are:

(getYValues 
(lambda (x)
    (* x x)
    )
 '() 
'(-5.0 -4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 ))

In Dr Racket it returns the correct result: (25.0 20.25 16.0 12.25 9.0 6.25 4.0 2.25 1.0 0.25 0.0 0.25 1.0 2.25 4.0 6.25 9.0 12.25 16.0 20.25)

But called from our Java application using kawa it returns: (25.0 20.25 16.0 12.25 9.0 6.25 4.0 2.25 1.0 0.25 ...)

Does anyone know why the list is cut off and half of it replaced by ...?

I use Scheme.eval to call the function

Update/solution

The following code solved my problem:

LList list = new LList();
try {
    list = (LList)scm.eval(schemeCall);
} catch (Throwable e) {
    e.printStackTrace();
}
double[] yValues = new double[LList.length(list)];
for (int i = 0; i<yValues.length;i++) {
    yValues[i] = ((DFloNum) list.get(i)).doubleValue();
}
Community
  • 1
  • 1
Marmoy
  • 8,009
  • 7
  • 46
  • 74

1 Answers1

1

Wild guess: it's possible that the list is complete, but only a part of it is displayed, for presentation purposes - the rest is assumed to be in the ... part. To check, print the length of the list, it must be correct even if not all the elements are shown.

Óscar López
  • 232,561
  • 37
  • 312
  • 386
  • Thanks for your answer. Scheme.eval returns an Object, which I cast to a string after which I extract the numbers using regex. Is there a way to get a list from the return value so I can get the length of it? – Marmoy May 17 '13 at 21:47
  • @Videre: It will be list (in the sense of Kawa/Scheme) already. Try `(length input)` and `(length output)`. – leppie May 17 '13 at 21:49
  • I don't think we're talking about the same thing. I figured it out, take a look at my updated question if you're interested. – Marmoy May 17 '13 at 22:19