Kawa JTable String[][] arrays

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Kawa JTable String[][] arrays

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?

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
Reply | Threaded
Open this post in threaded view
|

Re: Kawa JTable String[][] arrays

Tom Bousso
Hi Fabian,

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

-Tom

On Thu, Nov 9, 2017 at 1:06 AM, Fabian Boucsein <[hidden email]>
wrote:

> 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
>
Reply | Threaded
Open this post in threaded view
|

Re: Kawa JTable String[][] arrays

Damien Mattei
In reply to this post by Fabian Boucsein
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


Le Thursday 09 November 2017 10:06:13 Fabian Boucsein, vous avez écrit :

> 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
>


Reply | Threaded
Open this post in threaded view
|

Re: Kawa JTable String[][] arrays

Per Bothner
In reply to this post by Tom Bousso
On 11/09/2017 01:11 AM, Tom Bousso wrote:
> 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
[hidden email]   http://per.bothner.com/
Reply | Threaded
Open this post in threaded view
|

Re: Kawa JTable String[][] arrays

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?

Kind regards,
Fabian


Gesendet: Donnerstag, 09. November 2017 um 19:14 Uhr
Von: "Per Bothner" <[hidden email]>
An: "Tom Bousso" <[hidden email]>, "Fabian Boucsein" <[hidden email]>
Cc: [hidden email]
Betreff: Re: Kawa JTable String[][] arrays
On 11/09/2017 01:11 AM, Tom Bousso wrote:
> 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
[hidden email] http://per.bothner.com/
Reply | Threaded
Open this post in threaded view
|

Re: Kawa JTable String[][] arrays

Per Bothner
On 11/10/2017 07:44 AM, Fabian Boucsein wrote:
> 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
[hidden email]   http://per.bothner.com/