Discussion:
Kawa JTable String[][] arrays
Fabian Boucsein
2017-11-09 09:06:13 UTC
Permalink
Hello fellow Kawa scheme users,

i am experimenting with JTables in Kawa. I'm stuck with the creation of an String[][] array.
Is ist possible to create one?

Something like this in Java:
String[][] rowData = {
{ "Japan", "245" }, { "USA", "240" }, { "Italy", "220" }
}

Also i would like to say thank you, for the creation of such a pleasant to work with Scheme
implementation for the JVM. I love it!

Kind regards,
Fabian
Tom Bousso
2017-11-09 09:11:24 UTC
Permalink
Hi Fabian,

You can try something like this: (define data (String[][] (String[] "Japan"
"245") (String[] "Abc" "345")))

-Tom
Post by Fabian Boucsein
Hello fellow Kawa scheme users,
i am experimenting with JTables in Kawa. I'm stuck with the creation of an
String[][] array.
Is ist possible to create one?
String[][] rowData = {
{ "Japan", "245" }, { "USA", "240" }, { "Italy", "220" }
}
Also i would like to say thank you, for the creation of such a pleasant to work with Scheme
implementation for the JVM. I love it!
Kind regards,
Fabian
Per Bothner
2017-11-09 18:14:34 UTC
Permalink
Post by Tom Bousso
Hi Fabian,
You can try something like this: (define data (String[][] (String[] "Japan"
"245") (String[] "Abc" "345")))
Even better:

(define data::String[][] [["Japan" "245"] ["USA" "240"]])
--
--Per Bothner
***@bothner.com http://per.bothner.com/
Fabian Boucsein
2017-11-10 15:44:27 UTC
Permalink
Thank you very much Per and Tom.

Per's version works very fine for me. Although i think they should be almost the same. What does ::String[][]? And maybe could you explain the difference between string and String?

Kind regards,
Fabian


Gesendet: Donnerstag, 09. November 2017 um 19:14 Uhr
Von: "Per Bothner" <***@bothner.com>
An: "Tom Bousso" <***@gmail.com>, "Fabian Boucsein" <***@gmx.de>
Cc: ***@sourceware.org
Betreff: Re: Kawa JTable String[][] arrays
Post by Tom Bousso
Hi Fabian,
You can try something like this: (define data (String[][] (String[] "Japan"
"245") (String[] "Abc" "345")))
Even better:

(define data::String[][] [["Japan" "245"] ["USA" "240"]])
--
--Per Bothner
***@bothner.com http://per.bothner.com/
Per Bothner
2017-11-10 16:01:46 UTC
Permalink
Post by Fabian Boucsein
Thank you very much Per and Tom.
Per's version works very fine for me. Although i think they should be almost the same. What does ::String[][]? And maybe could you explain the difference between string and String?
'::TYPE' (or with a space as in ':: TYPE') is a "type specifier".
See https://www.gnu.org/software/kawa/Definitions.html.

(define data::String[][] [["Japan" "245"] ["USA" "240"]])

would probably be more readable as

(define data ::String[][] [["Japan" "245"] ["USA" "240"]])

(define data :: String[][] [["Japan" "245"] ["USA" "240"]])

Regardless it specifies that 'data' has the type "String[][]'.
Normally ["Japan" "245"] evaluates to an immutable vector,
but when the required type (in the static context) is a String[]
then the compiler converts it for you. Similarly for String[][]/

You can write java.lang.String[][] instead of String[][].
They're not quite the same in terms what conversions they
handle, but specify the same data type.

The '[]' means a Java array type (as opposed to the multi-dimensional Scheme arrays).

https://www.gnu.org/software/kawa/Standard-Types.html
explains 'string' versus 'String'.
--
--Per Bothner
***@bothner.com http://per.bothner.com/
Damien MATTEI
2017-11-09 09:35:43 UTC
Permalink
hello Fabian,

i never use JTables in java and not sure it exists something like that in Kawa,
as Scheme does not have multiple array dimensions i write some code do do it:
https://github.com/damien-mattei/library-FunctProg/blob/master/array.scm
i have test it with kawa and it works

i just checked the existence of multidimension array features for scheme and there exists the SRFI 25
https://srfi.schemers.org/srfi-25/srfi-25.html

the latest version of Kawa seems to implement it (i cannot test it on my old installation):
https://www.gnu.org/software/kawa/Arrays.html

hope something is matching the Jtable in a compatible way.
regards,
damien
Post by Fabian Boucsein
Hello fellow Kawa scheme users,
i am experimenting with JTables in Kawa. I'm stuck with the creation of an String[][] array.
Is ist possible to create one?
String[][] rowData = {
{ "Japan", "245" }, { "USA", "240" }, { "Italy", "220" }
}
Also i would like to say thank you, for the creation of such a pleasant to work with Scheme
implementation for the JVM. I love it!
Kind regards,
Fabian
Loading...