cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Instantly extract effect sizes, F-ratios, and FDR-adjusted p-values from your models with the Calculate Effects Sizes extension, available now in the JMP Marketplace!
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

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