<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Concat multiple list items together in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Concat-multiple-list-items-together/m-p/423801#M67293</link>
    <description>&lt;P&gt;Yes I may have been assuming the iterative(for) within iterative(for each row) would severely impact script performance but after building the example&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/12549"&gt;@SDF1&lt;/a&gt;&amp;nbsp;suggested the performance is surprisingly good.&lt;/P&gt;&lt;P&gt;Thanks for the comparison - I would have assumed the c++ would always be faster but it makes sense a table would always have more overhead. I wonder would "Begin Data Update" and/or "Private" table improve the table overhead?&lt;/P&gt;</description>
    <pubDate>Wed, 06 Oct 2021 03:13:35 GMT</pubDate>
    <dc:creator>ts2</dc:creator>
    <dc:date>2021-10-06T03:13:35Z</dc:date>
    <item>
      <title>Concat multiple list items together</title>
      <link>https://community.jmp.com/t5/Discussions/Concat-multiple-list-items-together/m-p/422845#M67198</link>
      <description>&lt;P&gt;Using JMP12.2 - I'm looking for a fast way to concat list items together from two different lists in a 1 to 1 fashion - assuming the lists have the same number of items. This will be used For Each Row in very large tables - so I prefer no iterative function if possible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example of what I want to achieve:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;list1 = {"a","b","c","d","e","f","g"};&lt;/P&gt;&lt;P&gt;list2 = {"1","2","3","4","5","6","7"};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Acceptable result can be a string or list. If string separated by delimiters.&lt;/P&gt;&lt;P&gt;List result:&amp;nbsp; {"a,1","b,2","c,3","d,4","e,5","f,6","g,7"};&lt;/P&gt;&lt;P&gt;String result:&amp;nbsp;"a:1,b:2,c:3,d:4,e:5,f:6,g:7";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:58:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Concat-multiple-list-items-together/m-p/422845#M67198</guid>
      <dc:creator>ts2</dc:creator>
      <dc:date>2023-06-09T19:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Concat multiple list items together</title>
      <link>https://community.jmp.com/t5/Discussions/Concat-multiple-list-items-together/m-p/422881#M67200</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/5193"&gt;@ts2&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Depending on what you want to do with the results, you might approach it a couple different ways. I know you don't want to do iterative functions, but in order to get the right output where the elements of one list are connected to the elements of another list, I think you have to do a For Loop. You could also consider doing an associative array.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Below is some JSL that might help you get started on a solution.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

list1 = {"a","b","c","d","e","f","g"};

list2 = {"1","2","3","4","5","6","7"};


AA = Associative Array(List1, List2);

i=.;
result1={};
For(i=1, i&amp;lt;=nitems(list1), i++,
	result1[i]=list1[i]||":"||list2[i]
);

result 2 = EvalList({Concat Items(result1, ", ")});

Show(result1);
Show(result2);
Show (AA);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hope this helps!,&lt;/P&gt;&lt;P&gt;DS&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 14:09:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Concat-multiple-list-items-together/m-p/422881#M67200</guid>
      <dc:creator>SDF1</dc:creator>
      <dc:date>2021-10-01T14:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Concat multiple list items together</title>
      <link>https://community.jmp.com/t5/Discussions/Concat-multiple-list-items-together/m-p/423035#M67215</link>
      <description>&lt;P&gt;JSL loops have an undeservedly bad reputation. If the guts of the loop do much work, the loop's overhead will usually not matter much. And any solution without a JSL loop is going to involve a loop somewhere else, perhaps in C++ which will be a bit faster, but still. Anyway, here's a comparison of two methods, one involving a JSL loop and one using a loop hidden away in JMP's C++ code.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Graph showing crossover times of the two algorithms at around 39,000 elements." style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/36243i14634380008957B3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Graph showing crossover times of the two algorithms at around 39,000 elements." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Graph showing crossover times of the two algorithms at around 39,000 elements.&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dtGraph = New Table( "stats",
	Add Rows( 0 ),
	New Column( "size", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [] ) ),
	New Column( "table time", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [] ) ),
	New Column( "loop time", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [] ) )
);

For( n = 1, n &amp;lt; 1e7, n *= 2,
	dtGraph &amp;lt;&amp;lt; addrows( 1 );
	dtGraph:size[N Rows( dtGraph )] = n * 3;// 3 items repeated...
	list1 = Repeat( {"a", "b", "c"}, n );
	list2 = Repeat( {"1", "2", "3"}, n );


	start = HP Time(); // data table method begins here
	dt = New Table( "temp",
		New Column( "a", Character, "Nominal", Set Values( list1 ) ),
		New Column( "b", Character, "Nominal", Set Values( list2 ) ),
		New Column( "c", Character, "Nominal", formula( a || ":" || b ) ),
		invisible
	);
	dt &amp;lt;&amp;lt; runformulas;
	result = dt:c &amp;lt;&amp;lt; getvalues;
	Close( dt, nosave );
	stop = HP Time(); // data table method ends here
	Show( stop - start );
	result = Concat Items( result, "," );
	Show( Length( result ), Left( result, 100 ) );
	dtGraph:table time[N Rows( dtGraph )] = (stop - start) / 1e6;


	result = {};
	start = HP Time(); // loop method begins here
	While(
		a = Remove From( list1, 1 );
		b = Remove From( list2, 1 );
		N Items( a ); // as long as something was removed...
	, // do this...
		Insert Into( result, a[1] || ":" || b[1] )
	);
	stop = HP Time(); // loop method ends here
	Show( stop - start );
	result = Concat Items( result, "," );
	Show( Length( result ), Left( result, 100 ) );
	dtGraph:loop time[N Rows( dtGraph )] = (stop - start) / 1e6;
	Wait( 1 );
);

dtGraph &amp;lt;&amp;lt; Graph Builder(
	Size( 1200, 500 ),
	Show Control Panel( 0 ),
	Variables( X( :size ), Y( :table time ), Y( :loop time, Position( 1 ) ) ),
	Elements( Points( X, Y( 1 ), Y( 2 ), Legend( 5 ) ), Smoother( X, Y( 1 ), Y( 2 ), Legend( 6 ) ) ),
	SendToReport(
		Dispatch( {}, "size", ScaleBox, {Scale( "Log" ), Inc( 1 ), Minor Ticks( 1 )} ),
		Dispatch( {}, "table time", ScaleBox, {Scale( "Log" ), Format( "Best", 12 ), Inc( 1 ), Minor Ticks( 1 )} )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;JMP 14 is the oldest I have access to. I think the loop algorithm will have similar performance in JMP 12. It intentionally destroys the two lists as it processes them because older JMP versions did not have fast indexing in lists, but removing the first element is fast. The data table algorithm is first in the loop so it can use the lists before they are destroyed.&lt;/P&gt;&lt;P&gt;Looking back at the JSL, I shouldn't claim either algorithm is simpler or easier to follow.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 23:00:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Concat-multiple-list-items-together/m-p/423035#M67215</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2021-10-01T23:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: Concat multiple list items together</title>
      <link>https://community.jmp.com/t5/Discussions/Concat-multiple-list-items-together/m-p/423801#M67293</link>
      <description>&lt;P&gt;Yes I may have been assuming the iterative(for) within iterative(for each row) would severely impact script performance but after building the example&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/12549"&gt;@SDF1&lt;/a&gt;&amp;nbsp;suggested the performance is surprisingly good.&lt;/P&gt;&lt;P&gt;Thanks for the comparison - I would have assumed the c++ would always be faster but it makes sense a table would always have more overhead. I wonder would "Begin Data Update" and/or "Private" table improve the table overhead?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 03:13:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Concat-multiple-list-items-together/m-p/423801#M67293</guid>
      <dc:creator>ts2</dc:creator>
      <dc:date>2021-10-06T03:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: Concat multiple list items together</title>
      <link>https://community.jmp.com/t5/Discussions/Concat-multiple-list-items-together/m-p/423802#M67294</link>
      <description>&lt;P&gt;Thank you this works great. Even though it uses an iterative function it has good performance.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 03:16:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Concat-multiple-list-items-together/m-p/423802#M67294</guid>
      <dc:creator>ts2</dc:creator>
      <dc:date>2021-10-06T03:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Concat multiple list items together</title>
      <link>https://community.jmp.com/t5/Discussions/Concat-multiple-list-items-together/m-p/423805#M67295</link>
      <description>&lt;P&gt;My issue is solved - this is more a FYI for you and others who may find it useful.&lt;/P&gt;&lt;P&gt;I do have access to JMP14.3 but the script needs to run on JMP12.2 for compatibility within my organization.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried your analysis and for JMP14.3 got similar results as you - probably some differences in computing power.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ts2_0-1633492048334.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/36337iBAFE921B821EF07D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ts2_0-1633492048334.png" alt="ts2_0-1633492048334.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However, JMP12.2 the performance of the loop goes completely out of line. I have to kill JMP.exe process after 98304 as the time was increasing exponentially and never would've hit the 24th row:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ts2_1-1633492185490.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/36338iF7C68D8F41BD5148/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ts2_1-1633492185490.png" alt="ts2_1-1633492185490.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 03:55:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Concat-multiple-list-items-together/m-p/423805#M67295</guid>
      <dc:creator>ts2</dc:creator>
      <dc:date>2021-10-06T03:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: Concat multiple list items together</title>
      <link>https://community.jmp.com/t5/Discussions/Concat-multiple-list-items-together/m-p/423813#M67297</link>
      <description>&lt;P&gt;I made a mess of that! Here's an updated version that will probably work correctly in older versions of JMP:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dtGraph = New Table( "stats",
	Add Rows( 0 ),
	New Column( "size", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [] ) ),
	New Column( "table time", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [] ) ),
	New Column( "loop time", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [] ) )
);

For( n = 1, n &amp;lt; 1e7, n *= 2,
	dtGraph &amp;lt;&amp;lt; addrows( 1 );
	dtGraph:size[N Rows( dtGraph )] = n * 3;// 3 items repeated...
	list1 = Repeat( {"a", "b", "c"}, n );
	list2 = Repeat( {"1", "2", "3"}, n );


	start = HP Time(); // data table method begins here
	dt = New Table( "temp",
		New Column( "a", Character, "Nominal", Set Values( list1 ) ),
		New Column( "b", Character, "Nominal", Set Values( list2 ) ),
		New Column( "c", Character, "Nominal", formula( a || ":" || b ) ),
		invisible
	);
	dt &amp;lt;&amp;lt; runformulas;
	result = dt:c &amp;lt;&amp;lt; getvalues;
	Close( dt, nosave );
	stop = HP Time(); // data table method ends here
	Show( stop - start );
	result = Concat Items( result, "," );
	Show( Length( result ), Left( result, 100 ) );
	dtGraph:table time[N Rows( dtGraph )] = (stop - start) / 1e6;


	result = {};
	start = HP Time(); // loop method begins here
	While(
		aa = Remove From( list1, 1 );
		bb = Remove From( list2, 1 );
		N Items( aa ); // as long as something was removed...
	, // do this...
		Insert Into( result, aa[1] || ":" || bb[1], 1 ) // &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; here 
	);
	result=reverse(result); // &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; and here 
	stop = HP Time(); // loop method ends here
	Show( stop - start );
	result = Concat Items( result, "," );
	Show( Length( result ), Left( result, 100 ) );
	dtGraph:loop time[N Rows( dtGraph )] = (stop - start) / 1e6;
	Wait( 1 );
);

dtGraph &amp;lt;&amp;lt; Graph Builder(
	Size( 1200, 500 ),
	Show Control Panel( 0 ),
	Variables( X( :size ), Y( :table time ), Y( :loop time, Position( 1 ) ) ),
	Elements( Points( X, Y( 1 ), Y( 2 ), Legend( 5 ) ), Smoother( X, Y( 1 ), Y( 2 ), Legend( 6 ) ) ),
	SendToReport(
		Dispatch( {}, "size", ScaleBox, {Scale( "Log" ), Inc( 1 ), Minor Ticks( 1 )} ),
		Dispatch( {}, "table time", ScaleBox, {Scale( "Log" ), Format( "Best", 12 ), Inc( 1 ), Minor Ticks( 1 )} )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;see &lt;LI-MESSAGE title="Fast List" uid="28947" url="https://community.jmp.com/t5/Uncharted/Fast-List/m-p/28947#U28947" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp; for an explanation; I was concentrating on the RemoveFrom function and forgetting about the Insert Into function.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Insert Into needs a 3rd argument to insert at the beginning of the list, and then a reverse when done." style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/36342i89F578D5DC798E1B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Insert Into needs a 3rd argument to insert at the beginning of the list, and then a reverse when done." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Insert Into needs a 3rd argument to insert at the beginning of the list, and then a reverse when done.&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I also renamed the variables in the loop so they would not be using the data table columns as temporaries.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 08:36:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Concat-multiple-list-items-together/m-p/423813#M67297</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2021-10-06T08:36:38Z</dc:date>
    </item>
  </channel>
</rss>

