<?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: remove elements in a list in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/remove-elements-in-a-list/m-p/50866#M28904</link>
    <description>&lt;P&gt;You would use the Remove() function. See the scripting index&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Help==&amp;gt;Scripting Index&lt;/P&gt;
&lt;P&gt;for details.&lt;/P&gt;
&lt;P&gt;I strongly suggest you read the Scripting Guide.&amp;nbsp; It contains a detail on how to manipulate lists&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Help==&amp;gt;Books==&amp;gt;Scripting Guide&lt;/P&gt;</description>
    <pubDate>Wed, 07 Feb 2018 16:39:20 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2018-02-07T16:39:20Z</dc:date>
    <item>
      <title>remove elements in a list</title>
      <link>https://community.jmp.com/t5/Discussions/remove-elements-in-a-list/m-p/50865#M28903</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;someone can help me.....i have two lists like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;MYLIST = {:empty, :empty2, :Name("A:k"), :Name("A:m"), :Name("A:x"), :Name("A:y"), :NA, :Name("D:3"), :Name("D:6"), :Name("D:8")};
DELCOLS= {:empty, :empty2};&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;i would like remove the elements of list DELCOLS from&amp;nbsp;MYLIST&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;expected results:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt; MYLIST = {:Name("A:k"), :Name("A:m"), :Name("A:x"), :Name("A:y"), :NA, :Name("D:3"), :Name("D:6"), :Name("D:8")}  
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks in advance&lt;/P&gt;
&lt;P&gt;Gianpaolo&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 17:17:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/remove-elements-in-a-list/m-p/50865#M28903</guid>
      <dc:creator>gianpaolo</dc:creator>
      <dc:date>2018-02-07T17:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: remove elements in a list</title>
      <link>https://community.jmp.com/t5/Discussions/remove-elements-in-a-list/m-p/50866#M28904</link>
      <description>&lt;P&gt;You would use the Remove() function. See the scripting index&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Help==&amp;gt;Scripting Index&lt;/P&gt;
&lt;P&gt;for details.&lt;/P&gt;
&lt;P&gt;I strongly suggest you read the Scripting Guide.&amp;nbsp; It contains a detail on how to manipulate lists&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Help==&amp;gt;Books==&amp;gt;Scripting Guide&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 16:39:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/remove-elements-in-a-list/m-p/50866#M28904</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-02-07T16:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: remove elements in a list</title>
      <link>https://community.jmp.com/t5/Discussions/remove-elements-in-a-list/m-p/50867#M28905</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;is right, the Scripting Index and Scripting Guide are excellent resources.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To help you along the way though, check out the &lt;A href="http://www.jmp.com/support/help/13-2/For.shtml%23383033" target="_self"&gt;For()&lt;/A&gt; loop, &lt;A href="http://www.jmp.com/support/help/13-2/Manipulating_lists.shtml#339817" target="_self"&gt;Remove From()&lt;/A&gt;, &lt;A href="http://www.jmp.com/support/help/13-2/List_Operators.shtml#309457" target="_self"&gt;As List()&lt;/A&gt; and &lt;A href="http://www.jmp.com/support/help/13-2/Indexing_into_a_Matrix_or_List_with_Another_Matr.shtml#685191" target="_self"&gt;Loc()&lt;/A&gt; functions.&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;MYLIST = {:empty, :empty2, :Name( "A:k" ), :Name( "A:m" ), :Name( "A:x" ), :Name( "A:y" ), :NA,
:Name( "D:3" ), :Name( "D:6" ), :Name( "D:8" )};
DELCOLS = {:empty, :empty2};

For( i = 1, i &amp;lt;= N Items( delcols ), i++,
	Remove From( mylist, As List( Loc( mylist, delcols[i] ) ) )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 17:30:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/remove-elements-in-a-list/m-p/50867#M28905</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2018-02-07T17:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: remove elements in a list</title>
      <link>https://community.jmp.com/t5/Discussions/remove-elements-in-a-list/m-p/50884#M28912</link>
      <description>&lt;P&gt;Jeff's code is great&amp;nbsp;and use a clever way to&amp;nbsp;remove any multiple instances of the unwanted items.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to illustrate that there's often more than one way to do things in JSL: here's an alternative approach using Associative Arrays.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(Note, all&amp;nbsp;multiples&amp;nbsp;would be removed)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;MYLIST = {:empty, :empty2, :Name("A:k"), :Name("A:m"), :Name("A:x"), :Name("A:y"), :NA, :Name("D:3"), :Name("D:6"), :Name("D:8")};
DELCOLS = {:empty, :empty2};

// Remove DELCOLS from MYLIST. Retains original order of items. 
AA = Associative Array(MYLIST, 1 :: N Items(MYLIST));
MYLIST = (AA &amp;lt;&amp;lt; Remove(Associative Array(DELCOLS)) &amp;lt;&amp;lt; get keys)[Rank(AA &amp;lt;&amp;lt; get values)];

// If order is not important, this simpler version works (items sorted alphabetically)
MYLIST_sorted = Associative Array(MYLIST) &amp;lt;&amp;lt; Remove(Associative Array(DELCOLS)) &amp;lt;&amp;lt; get keys;

Show(MYLIST, MYLIST_sorted);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 23:56:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/remove-elements-in-a-list/m-p/50884#M28912</guid>
      <dc:creator>ms</dc:creator>
      <dc:date>2018-02-07T23:56:30Z</dc:date>
    </item>
  </channel>
</rss>

