- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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);
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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 );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.