cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP Security Notice: CVE-2026-109618 and CVE-2026-109619

    JMP promptly initiated a review of its products, services, and relevant infrastructure for exposure to CVE-2026-109618 and CVE-2026-109619.

    Our assessment of JMP products has not identified exposure to these vulnerabilities. Where remediation was required within supporting environments, appropriate security updates and controls have been applied and validated.

    We have identified no evidence of successful exploitation or unauthorized access to JMP systems or customer information associated with these vulnerabilities.

    JMP continues to monitor the issue and relevant vendor guidance. No action is required by JMP customers at this time.

  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.

Discussions

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

Nested Lists

I have somehow generated a nested list of columns due to them having been initially grouped.  I would like to remove the nesting to have a continuous list of columns I can act on.

 

Instead of {{:A, :B, :C}, (:D, :E, :F}}, I would like to get to {:A, :B, :C, :D, :E, :F}


Slán



SpannerHead
5 REPLIES 5
mmarchandFSLR
Level VI

Re: Nested Lists

Here's one way, assuming the items inside the outer list are all lists.  If they might not be, you just need to add a little more code to handle it.

 

Names Default to Here( 1 );
this_list = {{:A, :B, :C}, {:D, :E, :F}};
new_list = {};
For Each( {v, i}, this_list,
	For Each( {val, idx}, v,
		Insert Into( new_list, val )
	)
);
SpannerHead
Level VI

Re: Nested Lists

Had to tweak this.  Works now.  Thanks.

 

For Each( {val, idx}, this_list,
		Insert Into( new_list, val )
);	

 


Slán



SpannerHead
mmarchandFSLR
Level VI

Re: Nested Lists

Ah, sorry.  I was testing on strings, and I forgot that inserting a list into a list actually inserts the unevaluated items of the list.  If you have any columns that are not inside of a nested list, they will be inserted as missing, for example:

 

Names Default To Here( 1 );
this_list = {{:A, :B, :C}, :D, {:E, :F, :G}};
new_list = {};
For Each( {v, i}, this_list, Insert Into( new_list, v ) );

//{:A, :B, :C, ., :E, :F, :G}

You can solve the issue by using Name Expr():

 

Names Default To Here( 1 );
this_list = {{:A, :B, :C}, :D, {:E, :F, :G}};
new_list = {};
For Each( {v, i}, this_list, Insert Into( new_list, Name Expr( v ) ) );

//{:A, :B, :C, :D, :E, :F, :G}
txnelson
Super User

Re: Nested Lists

You just need to concatenate the individual lists;

Names Default To Here( 1 );
l1 = {{:A, :B, :C}, {:D, :E, :F}};

l2 = l1[1] || l1[2];

I suggest you take the time to read the section of the Scripting Guide on the creation and manipulation of Lists.

Jim
pmroz
Super User

Re: Nested Lists

Building on Jim's solution.  If you have more than two sublists:

Names Default To Here( 1 );
l1 = {{:A, :B, :C}, {:D, :E, :F}, {:G, :H, :I, :J}};
l3 = {};
for (i = 1, i <= nitems(l1), i++,
	insertinto(l3, l1[i]);
);
print(l3);
{:A, :B, :C, :D, :E, :F, :G, :H, :I, :J}

Recommended Articles