This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: Java classes in Kawa
- From: Per Bothner <per at bothner dot com>
- To: Chris Bitmead <chris at bitmead dot com>
- Cc: kawa <kawa at sources dot redhat dot com>
- Date: Wed, 10 Jul 2002 11:41:43 -0700
- Subject: Re: Java classes in Kawa
- References: <3D2C4140.2060201@bitmead.com>
Chris Bitmead wrote:
I was trying to implement a sort function in kawa.
The following works to sort vectors:
(define-simple-class <comparator> (<java.util.Comparator>)
(function init-keyword: function:)
((compare (o1 :: <java.lang.Object>) (o2 :: <java.lang.Object>)) :: <int>
((slot-ref (this) 'function) o1 o2)))
(define (sort function list)
(let ((comparator (make <comparator> function: function)))
(invoke-static <java.util.Collections> 'sort list comparator)
list))
(define (comp x1 x2) (cond ((< x1 x2) -1) ((> x1 x2) 1) (else 0)))
(define lu (vector 12 8 7 44 -1 -7 9 8))
(define ls (sort comp lu))
Sorting lists doesn't yet work, because some methods are not
implemented. I'm looking at that now.
--
--Per Bothner
per@bothner.com http://www.bothner.com/per/