<?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: Is there a quick way to make a large list without a for loop? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Is-there-a-quick-way-to-make-a-large-list-without-a-for-loop/m-p/14367#M13424</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This profiler tool will come in handy.&amp;nbsp; Thanks for sharing it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like you are right, the reason it doesn't appear to run faster is b/c there are larger bottle necks in the code.&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;It does seem that the "::" matrix code runs faster than the for loop which is intuitive.&amp;nbsp; I get that from, comparing %'s in line 10+11 versus %'s in line 31.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My current code won't ever compare large sets of data, but I was still curious b/c I foresee building similar scripts for larger amounts of data and getting rid of for loops is a general sure fire way to make code faster.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Sep 2015 20:09:05 GMT</pubDate>
    <dc:creator>msharp</dc:creator>
    <dc:date>2015-09-17T20:09:05Z</dc:date>
    <item>
      <title>Is there a quick way to make a large list without a for loop?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-quick-way-to-make-a-large-list-without-a-for-loop/m-p/14363#M13420</link>
      <description>&lt;P&gt;Many programming languages have some form.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example to make a &lt;SPAN style="font-size: 13.3333330154419px; line-height: 1.5em;"&gt;list from 1 to 100:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;list = 1:100,&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;list = range(1,100)&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;list = {1..100}&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;list = seq(1,100)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know! I couldn't find anything in the scripting guide.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 17:04:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-quick-way-to-make-a-large-list-without-a-for-loop/m-p/14363#M13420</guid>
      <dc:creator>msharp</dc:creator>
      <dc:date>2019-09-13T17:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a quick way to make a large list without a for loop?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-quick-way-to-make-a-large-list-without-a-for-loop/m-p/14364#M13421</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;a=3;
b=9;
AsList(a::b)[1]&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Results in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;{3, 4, 5, 6, 7, 8, 9}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;several things going on here: a::b makes a matrix of one row: [3 4 5 6 7 8 9]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AsList( ... ) converts the matrix to a list of lists (because it is really two dimensional, with one of the dimensions being just 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[1] extracts the inner list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you just want the matrix rather than the list.&amp;nbsp; If you are interested in fast code, use the built in matrix functions when you can.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is not a magical iterator from some other programming language; it &lt;STRONG&gt;will&lt;/STRONG&gt; create the full matrix and list in memory, so you probably don't want to make a list of a billion items.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 17:06:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-quick-way-to-make-a-large-list-without-a-for-loop/m-p/14364#M13421</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2019-09-13T17:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a quick way to make a large list without a for loop?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-quick-way-to-make-a-large-list-without-a-for-loop/m-p/14365#M13422</link>
      <description>&lt;P&gt;Thanks this is helpful.&amp;nbsp; I was hoping this would speed up my code, but feels like the for loop has similar speeds which surprises me.&amp;nbsp; Any suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

t1 = tick seconds();

numberarray = Function({list},
&amp;nbsp; temparray = Associative Array(list);
&amp;nbsp; tempnum = nitems(temparray &amp;lt;&amp;lt; Get Keys);
&amp;nbsp; tempitems = temparray &amp;lt;&amp;lt; Get Keys;
&amp;nbsp; templist = {};
&amp;nbsp; For(l=1, l&amp;lt;=tempnum, l++, insertinto(templist, l));
&amp;nbsp; temparray = Associative Array(tempitems, templist);
&amp;nbsp; //return(temparray)
&amp;nbsp; );

for(i=1, i&amp;lt;=100,i++,
&amp;nbsp; array = numberarray( Column(dt, 1) );
&amp;nbsp; array2 = numberarray( Column(dt, 2) );
&amp;nbsp; array3 = numberarray( Column(dt, 3) );
&amp;nbsp; array4 = numberarray( Column(dt, 4) );
&amp;nbsp; array5 = numberarray( Column(dt, 5) ););

t2 = tick seconds();
Print( Concat( Char( t2 - t1 ), " seconds." ) );

t1 = tick seconds();

numberarray = Function({list},
&amp;nbsp; temparray = Associative Array(list);
&amp;nbsp; tempnum = nitems(temparray &amp;lt;&amp;lt; Get Keys);
&amp;nbsp; tempitems = temparray &amp;lt;&amp;lt; Get Keys;
&amp;nbsp; temparray = Associative Array(tempitems,&amp;nbsp; 1::tempnum);
&amp;nbsp; );

for(i=1, i&amp;lt;=100,i++,
&amp;nbsp; array = numberarray( Column(dt, 1) );
&amp;nbsp; array2 = numberarray( Column(dt, 2) );
&amp;nbsp; array3 = numberarray( Column(dt, 3) );
&amp;nbsp; array4 = numberarray( Column(dt, 4) );
&amp;nbsp; array5 = numberarray( Column(dt, 5) ););

t2 = tick seconds();
Print( Concat( Char( t2 - t1 ), " seconds." ) );
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 17:02:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-quick-way-to-make-a-large-list-without-a-for-loop/m-p/14365#M13422</guid>
      <dc:creator>msharp</dc:creator>
      <dc:date>2019-09-13T17:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a quick way to make a large list without a for loop?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-quick-way-to-make-a-large-list-without-a-for-loop/m-p/14366#M13423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nice performance test.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;JSL has a profiler that can help answer performance questions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="9885_profiler.PNG" style="width: 454px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/2188iD92D5336D65FB1D9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="9885_profiler.PNG" alt="9885_profiler.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ran it to get this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="9886_profiler2.PNG" style="width: 537px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/2189iA2FF362E76B194E6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="9886_profiler2.PNG" alt="9886_profiler2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;which tells me setting the values into the associative array is a bottle-neck in this code.&amp;nbsp; (line 10 vs line 11.)&amp;nbsp; (Line 23 probably includes opening the log the first time, ignore that; 42 is more representative.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Big class only has 40 rows.&amp;nbsp; If you had many more rows (10K?) you might see other bottle-necks.&amp;nbsp; Don't call temparray&amp;lt;&amp;lt;getkeys twice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like you are trying to create a lookup table of small consecutive integers for each unique value in the column.&amp;nbsp; There may be a clever way to do this, but I don't see it right now.&amp;nbsp; Maybe someone else will...maybe some database join operation?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2016 00:39:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-quick-way-to-make-a-large-list-without-a-for-loop/m-p/14366#M13423</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2016-10-19T00:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a quick way to make a large list without a for loop?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-quick-way-to-make-a-large-list-without-a-for-loop/m-p/14367#M13424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This profiler tool will come in handy.&amp;nbsp; Thanks for sharing it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like you are right, the reason it doesn't appear to run faster is b/c there are larger bottle necks in the code.&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;It does seem that the "::" matrix code runs faster than the for loop which is intuitive.&amp;nbsp; I get that from, comparing %'s in line 10+11 versus %'s in line 31.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My current code won't ever compare large sets of data, but I was still curious b/c I foresee building similar scripts for larger amounts of data and getting rid of for loops is a general sure fire way to make code faster.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Sep 2015 20:09:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-quick-way-to-make-a-large-list-without-a-for-loop/m-p/14367#M13424</guid>
      <dc:creator>msharp</dc:creator>
      <dc:date>2015-09-17T20:09:05Z</dc:date>
    </item>
  </channel>
</rss>

