cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
tom_abramov
Level V

Inserting List to List with JSL

Hello,

I dont know how to insert list to list intead of values of list to list.

Insert into makes it one big list.

I need the following to be done:

MainList = {};
AList = {"a1", "a2"};
BList = {"b1", "b2"};
//Result I need:
MainList = {{"a1", "a2"}, {"b1", "b2"}};

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
ian_jmp
Level X

Re: Inserting List to List with JSL

Please try:

NamesDefaultToHere(1);
MainList = {};
AList = {"a1", "a2"};
BList = {"b1", "b2"};
InsertInto(MainList, EvalList(List(AList)));
InsertInto(MainList, EvalList(List(BList)));
Print(MainList);

 

View solution in original post

4 REPLIES 4
ian_jmp
Level X

Re: Inserting List to List with JSL

Please try:

NamesDefaultToHere(1);
MainList = {};
AList = {"a1", "a2"};
BList = {"b1", "b2"};
InsertInto(MainList, EvalList(List(AList)));
InsertInto(MainList, EvalList(List(BList)));
Print(MainList);

 

Re: Inserting List to List with JSL

Here is another solution, related to the one provided by @ian_jmp .

 

Names Default to Here( 1 );

main list = List();

a = List( "a1", "a2" );
b = List( "b1", "b2" );

Insert Into( main list, List( a ) );
Insert Into( main list, List( b ) );

main list = Eval List( main list );

Show( main list );
txnelson
Super User

Re: Inserting List to List with JSL

This is a different way to handle this

NamesDefaultToHere(1);
MainList = {};
AList = {"a1", "a2"};
BList = {"b1", "b2"};

mainlist[1]=alist;
mainlist[2]=blist;
Jim
pmroz
Super User

Re: Inserting List to List with JSL

If you want a list of lists you might also consider using associative arrays.

MainList = associative array();
AList = {"a1", "a2"};
BList = {"b1", "b2"};
mainlist["A"] = alist;
mainlist["B"] = blist;
show(mainlist);

Result:

mainlist = ["A" => {"a1", "a2"}, "B" => {"b1", "b2"}];

Check the documentation for more information about associative arrays - they're extremely powerful.

Recommended Articles