<?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: Reorder a list or column, according to an interlacing pattern in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Reorder-a-list-or-column-according-to-an-interlacing-pattern/m-p/393746#M64412</link>
    <description>&lt;P&gt;This seems to be getting correct matrices (might require transposing if starting matrix is built differently)&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);

// Create arbitrary sequence
a = 1::30;
f = 3;
b = Mod(a+f-1,f);
m_interlaced = [];
For(i = 0, i &amp;lt;= f-1, i++,
	m_interlaced = m_interlaced |/ a[Loc(b, i)];
);
show(m_interlaced);

Names Default To Here(1);

// Create arbitrary sequence
a = 1::99;
f = 2;
b = Mod(a+f-1,f);
m_interlaced = [];
For(i = 0, i &amp;lt;= f-1, i++,
	m_interlaced = m_interlaced |/ a[Loc(b, i)];
);
show(m_interlaced);

&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Jun 2021 17:20:37 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2021-06-16T17:20:37Z</dc:date>
    <item>
      <title>Reorder a list or column, according to an interlacing pattern</title>
      <link>https://community.jmp.com/t5/Discussions/Reorder-a-list-or-column-according-to-an-interlacing-pattern/m-p/393729#M64410</link>
      <description>&lt;P&gt;I am referring to interlacing as in older interlaced video techniques where the lines of pixels on your screen would be rendered in an alternating pattern of every second or every third row. (&lt;A href="https://en.wikipedia.org/wiki/Interlaced_video" target="_blank" rel="noopener"&gt;https://en.wikipedia.org/wiki/Interlaced_video&lt;/A&gt;&amp;nbsp;has a good gif of the process)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so if you have your rows(1,2,3,4,.....99)&lt;/P&gt;&lt;P&gt;they would be rendered (factor 2) in the order rows(1,3,5,7......97,99,2,4,6,.....98)&lt;/P&gt;&lt;P&gt;or (factor 3) as rows(1,4,7.....2,5,8.....3,6,9....)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to write a script that will reorder a sequence of arbitrary length according to this pattern with JSL but I can't quite figure out how to build an index to reorder this. I'm currently trying to work out matrix math to accomplish this but maybe a for loop would be smarter/easier?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Create arbitrary sequence
a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,21,22,23,24,25,26,27,28];
f = 3 // interlacing factor&lt;BR /&gt;
//Start trying to work out an index or grouping for a future sorting op
b = mod(a+f-1),3);
//b = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 2, 0, 1, 2, 0, 1, 2, 0]&lt;BR /&gt;
// ????&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:49:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Reorder-a-list-or-column-according-to-an-interlacing-pattern/m-p/393729#M64410</guid>
      <dc:creator>CaseyL</dc:creator>
      <dc:date>2023-06-09T19:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder a list or column, according to an interlacing pattern</title>
      <link>https://community.jmp.com/t5/Discussions/Reorder-a-list-or-column-according-to-an-interlacing-pattern/m-p/393741#M64411</link>
      <description>&lt;P&gt;EDIT #2: Far below is incorrect. This code should work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27];

fact = 3;

x = shape(a, ceiling(nrow(a)/fact));
try(x[(nrow(a)+1)::(nrow(x)*ncol(x))] = .);
x = shape(x`, 1);
x = x[loc(!ismissing(x))];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/////////////////////////&lt;/P&gt;
&lt;P&gt;#EDIT: I had to add an index to the end to prevent "start-over" when the factor does not evenly divide the number of rows&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/////////////&lt;/P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check out the Shape() command. Along with transposing, you can get what you are after--&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);

a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,21,22,23,24,25,26,27,28];

fact = 3;

shape(shape(a, ceiling(nrow(a)/fact))`, 1)`[1::nrow(a)]&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Brady&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 16:48:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Reorder-a-list-or-column-according-to-an-interlacing-pattern/m-p/393741#M64411</guid>
      <dc:creator>brady_brady</dc:creator>
      <dc:date>2021-06-18T16:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder a list or column, according to an interlacing pattern</title>
      <link>https://community.jmp.com/t5/Discussions/Reorder-a-list-or-column-according-to-an-interlacing-pattern/m-p/393746#M64412</link>
      <description>&lt;P&gt;This seems to be getting correct matrices (might require transposing if starting matrix is built differently)&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);

// Create arbitrary sequence
a = 1::30;
f = 3;
b = Mod(a+f-1,f);
m_interlaced = [];
For(i = 0, i &amp;lt;= f-1, i++,
	m_interlaced = m_interlaced |/ a[Loc(b, i)];
);
show(m_interlaced);

Names Default To Here(1);

// Create arbitrary sequence
a = 1::99;
f = 2;
b = Mod(a+f-1,f);
m_interlaced = [];
For(i = 0, i &amp;lt;= f-1, i++,
	m_interlaced = m_interlaced |/ a[Loc(b, i)];
);
show(m_interlaced);

&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 17:20:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Reorder-a-list-or-column-according-to-an-interlacing-pattern/m-p/393746#M64412</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-06-16T17:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder a list or column, according to an interlacing pattern</title>
      <link>https://community.jmp.com/t5/Discussions/Reorder-a-list-or-column-according-to-an-interlacing-pattern/m-p/393851#M64424</link>
      <description>&lt;P&gt;in JMP14 this returns "Argument should be list" I believe referring to where b is called in the Loc function. I tried to modify b with as list() but i don't understand the result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;seperately, what does |/ do and is it related to the concat operator ||?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;a = 1::30;
f = 3;
b = as list(Mod(a+f-1,f));
m_interlaced = [];
For(i = 0, i &amp;lt;= f-1, i++,
	m_interlaced = m_interlaced |/ a[Loc(b, i)];
);
show(m_interlaced);

/*:

m_interlaced = [](0, 1);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Jun 2021 20:31:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Reorder-a-list-or-column-according-to-an-interlacing-pattern/m-p/393851#M64424</guid>
      <dc:creator>CaseyL</dc:creator>
      <dc:date>2021-06-16T20:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder a list or column, according to an interlacing pattern</title>
      <link>https://community.jmp.com/t5/Discussions/Reorder-a-list-or-column-according-to-an-interlacing-pattern/m-p/394014#M64439</link>
      <description>&lt;P&gt;I luckily still had JMP14 installed so I could test it out. One "workaround" would be like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

// Create arbitrary sequence
a = Transpose(1::30);
f = 3;
b = AsList(Mod(a+f-1,f));
m_interlaced = [];
For(i = 0, i &amp;lt;= f-1, i++,
	m_interlaced = m_interlaced |/ a[Loc(b, i)];
);
show(m_interlaced);

//m_interlaced = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30];&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 11:46:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Reorder-a-list-or-column-according-to-an-interlacing-pattern/m-p/394014#M64439</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-06-17T11:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder a list or column, according to an interlacing pattern</title>
      <link>https://community.jmp.com/t5/Discussions/Reorder-a-list-or-column-according-to-an-interlacing-pattern/m-p/394526#M64488</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;[1::nrow(a)]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;removes the wrapped-around positions after the second shape, so unfortunately the wrong values are being truncated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used what you gave me to flag the wrapped around values (as 0's in this case but maybe NaN or something would be better?) so that they can be easily identified and excised at the end of the operation. I know I use way too many variables, please ignore the sloppiness.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;n = 28;						// Number of rows
f = 3;						// Interlacing factor (how many scans per frame)

q = ceiling(n/f);
r = q*f;
a = 1::r;

a[loc(a &amp;gt; n)] = 0;			//a = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 0 0];
s = shape(shape(a, q)`,1); 	//s = [1 4 7 10 13 16 19 22 25 28 2 5 8 11 14 17 20 23 26 0 3 6 9 12 15 18 21 24 27 0];
b = s[loc(s)];				//b = [1 4 7 10 13 16 19 22 25 28 2 5 8 11 14 17 20 23 26 3 6 9 12 15 18 21 24 27];
show(b);

c = [];
For(i = 1, i &amp;lt;= nrow(b), i++,
	c = c || a`[i] || b[i];
);
show(c`);					//c` gives a vector to copy/paste into a match() function that will translate progressive rows to interlaced rows&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 16:12:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Reorder-a-list-or-column-according-to-an-interlacing-pattern/m-p/394526#M64488</guid>
      <dc:creator>CaseyL</dc:creator>
      <dc:date>2021-06-18T16:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder a list or column, according to an interlacing pattern</title>
      <link>https://community.jmp.com/t5/Discussions/Reorder-a-list-or-column-according-to-an-interlacing-pattern/m-p/394536#M64492</link>
      <description>&lt;P&gt;Hi Casey,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are right--my apologies! Try this code, which sets extra values to missing before the initial transpose, so they can be weeded out with Loc() later.&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);

a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27];

fact = 3;

x = shape(a, ceiling(nrow(a)/fact));
try(x[(nrow(a)+1)::(nrow(x)*ncol(x))] = .);
x = shape(x`, 1);
x = x[loc(!ismissing(x))];
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Jun 2021 16:48:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Reorder-a-list-or-column-according-to-an-interlacing-pattern/m-p/394536#M64492</guid>
      <dc:creator>brady_brady</dc:creator>
      <dc:date>2021-06-18T16:48:25Z</dc:date>
    </item>
  </channel>
</rss>

