Choose Language Hide Translation Bar
Highlighted
Jeremy122
Level I

Possible to create x number of lists, where x is the number of loops in For statement?

Is there anyway to script in creating a variable number of lists depending on the number of loops in a for statement? I was thinking something like below would work, but no luck.

 

xyz = N Items( List1 );
NumOfSets = Divide To( xyz, 4 );
For( i = 1, i <= NumOfSets, i++,
	List( Concat( Set, Char( [i] ) ) )
);
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
pmroz
Super User

Re: Possible to create x number of lists, where x is the number of loops in For statement?

Something like this?  I'm creating a list of lists.

list1 = {"aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh"};

xyz = N Items( List1 );
NumOfSets = Divide To( xyz, 4 );

list_array = {};
set = "xyz";

For( i = 1, i <= NumOfSets, i++,
	list_array[i] = eval list(list( Concat( Set, Char(i) )));
);

list_array;

View solution in original post

2 REPLIES 2
Highlighted
pmroz
Super User

Re: Possible to create x number of lists, where x is the number of loops in For statement?

Something like this?  I'm creating a list of lists.

list1 = {"aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh"};

xyz = N Items( List1 );
NumOfSets = Divide To( xyz, 4 );

list_array = {};
set = "xyz";

For( i = 1, i <= NumOfSets, i++,
	list_array[i] = eval list(list( Concat( Set, Char(i) )));
);

list_array;

View solution in original post

Highlighted
Jeremy122
Level I

Re: Possible to create x number of lists, where x is the number of loops in For statement?

Yes, it looks like that will do the trick. Thank you
Article Labels

    There are no labels assigned to this post.