## JSL List to matrix ?

Contributor

Joined:

Jun 5, 2017

Prob: needed to get a list or matrix of numbers instead of characters;

String="1,2,3,4,5,6";

list=words(String,",");  //output --> {"1","2","3","4","5","6"}

required output ={1,2,3,4,5,6};

1 ACCEPTED SOLUTION

Accepted Solutions

Super User

Joined:

Jun 22, 2012

Solution

All Matrix, List and Character functions are available at

Help==>Scripting Index==>Functions

Here is a possible answer for you

``````Names Default To Here( 1 );
String = "1,2,3,4,5,6";
Eval( Parse( "Mat=[" || string || "];" ) );``````
Jim
4 REPLIES

Contributor

Joined:

Jun 5, 2017

No For loop should be used.

Community Manager

Joined:

Jun 23, 2011

Here's one way to do it without a For() loop.

``````String="1,2,3,4,5,6";
list=words(String,",");
//output --> {"1","2","3","4","5","6"}

x=new table("temp", new column("c", character, values(list)), private);
:c<< data type(numeric);
m = c<< get values;

close(x, nosave);

show(m);``````
-Jeff

Super User

Joined:

Jun 22, 2012

Solution

All Matrix, List and Character functions are available at

Help==>Scripting Index==>Functions

Here is a possible answer for you

``````Names Default To Here( 1 );
String = "1,2,3,4,5,6";
Eval( Parse( "Mat=[" || string || "];" ) );``````
Jim

Contributor

Joined:

Jun 5, 2017

Thank you Jim,
This is exactly i was looking for. Also Thanks for pointing to the link to explore other functions too.