<?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: Map Value function: Wrong results for different characters in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Map-Value-function-Inconsistent-results-for-subsequent-calls/m-p/515098#M74189</link>
    <description>&lt;P&gt;Sometimes JMP / JSL can be weird in how it handles expressions -- for instance, often times in a send function the arguments are sent unevaluated.&amp;nbsp; Although there is no send function here it would seem that something within the &lt;CODE class=" language-jsl"&gt;Filter Each()&lt;/CODE&gt; or &lt;CODE class=" language-jsl"&gt;Map Value()&lt;/CODE&gt; handles arguments in a weird way and handles the lookup oddly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, I cannot say that it is a bug but it does seem weird.&amp;nbsp; If I were you I'd contact JMP Support and show them that the first call (whether it's the &lt;CODE class=" language-jsl"&gt;{"b",1,2,3"}&lt;/CODE&gt; or the &lt;CODE class=" language-jsl"&gt;{"d",1,2,3}&lt;/CODE&gt;) works, while the second does not work.&amp;nbsp; Possible that it's a bug.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a work-around:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;wrap = Function( {filtered list, na_list},
	{Default Local},
	na_values = {};
	For Each( {value}, na_list,
		Insert Into( na_values, value );
		Insert Into( na_values, 1 );
	);
	Eval( Eval Expr( Filter Each( {value}, filtered list, Map Value( value, Expr( na_values ), Unmatched( 0 ) ) == 0 ) ) );
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jun 2022 17:50:29 GMT</pubDate>
    <dc:creator>ErraticAttack</dc:creator>
    <dc:date>2022-06-28T17:50:29Z</dc:date>
    <item>
      <title>Map Value function: Inconsistent results for subsequent calls</title>
      <link>https://community.jmp.com/t5/Discussions/Map-Value-function-Inconsistent-results-for-subsequent-calls/m-p/515081#M74188</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am new to JMP 16 and JSL but I am an experienced programmer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some reasons I want to use the "Map Value" function but this gives me wrong results.&lt;/P&gt;&lt;P&gt;What i want to achieve is to remove unwanted items given as a list from a list containing numbers and strings&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following function constructs a list for "Map Value" named na_values in the form {option1, 0, option2, 0, ...} from the na_list e.g. {option1, option2 ,...}&lt;/P&gt;&lt;P&gt;and filters it&amp;nbsp;using "Filter Each" and the Map Value" function.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;wrap = function({filtered list,na_list}, {Default Local},			
		na_values={};For Each( {value}, na_list, na_values=Insert(na_values,value);na_values=Insert(na_values,1););
		return(Filter Each({value}, filtered list, Map Value(value, na_values, Unmatched(0))==0;));		
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But it gives a wrong result if I call the function again with other parameters:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Show(wrap({"b",1, 2, 3},{"b"}));&amp;nbsp; // &amp;lt;--&amp;nbsp; returns {1,2,3} =&amp;gt; OK
Show(wrap({"d",1, 2, 3},{"d"}));&amp;nbsp; // &amp;lt;--&amp;nbsp; returns {"d",1,2,3} =&amp;gt; NOT OK, should be as above {1,2,3]

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What is wrong here? A bug in JMP? I am using version 16.0.0 (512257).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 17:02:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Map-Value-function-Inconsistent-results-for-subsequent-calls/m-p/515081#M74188</guid>
      <dc:creator>ThomasDickel</dc:creator>
      <dc:date>2023-06-09T17:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Map Value function: Wrong results for different characters</title>
      <link>https://community.jmp.com/t5/Discussions/Map-Value-function-Inconsistent-results-for-subsequent-calls/m-p/515098#M74189</link>
      <description>&lt;P&gt;Sometimes JMP / JSL can be weird in how it handles expressions -- for instance, often times in a send function the arguments are sent unevaluated.&amp;nbsp; Although there is no send function here it would seem that something within the &lt;CODE class=" language-jsl"&gt;Filter Each()&lt;/CODE&gt; or &lt;CODE class=" language-jsl"&gt;Map Value()&lt;/CODE&gt; handles arguments in a weird way and handles the lookup oddly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, I cannot say that it is a bug but it does seem weird.&amp;nbsp; If I were you I'd contact JMP Support and show them that the first call (whether it's the &lt;CODE class=" language-jsl"&gt;{"b",1,2,3"}&lt;/CODE&gt; or the &lt;CODE class=" language-jsl"&gt;{"d",1,2,3}&lt;/CODE&gt;) works, while the second does not work.&amp;nbsp; Possible that it's a bug.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a work-around:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;wrap = Function( {filtered list, na_list},
	{Default Local},
	na_values = {};
	For Each( {value}, na_list,
		Insert Into( na_values, value );
		Insert Into( na_values, 1 );
	);
	Eval( Eval Expr( Filter Each( {value}, filtered list, Map Value( value, Expr( na_values ), Unmatched( 0 ) ) == 0 ) ) );
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 17:50:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Map-Value-function-Inconsistent-results-for-subsequent-calls/m-p/515098#M74189</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2022-06-28T17:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Map Value function: Wrong results for different characters</title>
      <link>https://community.jmp.com/t5/Discussions/Map-Value-function-Inconsistent-results-for-subsequent-calls/m-p/515392#M74204</link>
      <description>&lt;P&gt;I'm not sure how you got your function to work without first initialising na_value as an empty list.&amp;nbsp; This works:&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);

filtered list = {"d",1, 2, 3};
na_list = {"d"};

na_values = {};			// &amp;lt;--- missing
For Each( {value}, na_list, 
	na_values=Insert(na_values,value);
	na_values=Insert(na_values,1);
);

f = Filter Each({value}, filtered list, 
	Map Value(value, na_values, Unmatched(0))==0;
);

show(f);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Jun 2022 07:55:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Map-Value-function-Inconsistent-results-for-subsequent-calls/m-p/515392#M74204</guid>
      <dc:creator>David_Burnham</dc:creator>
      <dc:date>2022-06-29T07:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: Map Value function: Wrong results for different characters</title>
      <link>https://community.jmp.com/t5/Discussions/Map-Value-function-Inconsistent-results-for-subsequent-calls/m-p/515399#M74205</link>
      <description>&lt;P&gt;Hello, you are right, I removed the initialization of na_values from my test function.&lt;/P&gt;&lt;P&gt;But the problem exists if I add the initialization of na_values to the function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;wrap = function({filtered list,na_list}, {Default Local},			
		&lt;STRONG&gt;na_values={}&lt;/STRONG&gt;;For Each( {value}, na_list, na_values=Insert(na_values,value);na_values=Insert(na_values,1););
		return(Filter Each({value}, filtered list, Map Value(value, na_values, Unmatched(0))==0;));		
);

Show(wrap({"b",1, 2, 3},{"b"})); // = {1, 2, 3}=&amp;gt; OK 
Show(wrap({"d",1, 2, 3},{"d"})); // = {"d", 1, 2, 3} =&amp;gt; Not OK ! =&amp;gt; expected {1, 2, 3}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please try yourself the above code.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 08:04:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Map-Value-function-Inconsistent-results-for-subsequent-calls/m-p/515399#M74205</guid>
      <dc:creator>ThomasDickel</dc:creator>
      <dc:date>2022-06-29T08:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: Map Value function: Wrong results for different characters</title>
      <link>https://community.jmp.com/t5/Discussions/Map-Value-function-Inconsistent-results-for-subsequent-calls/m-p/515404#M74206</link>
      <description>&lt;P&gt;In your example&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Show(wrap({"b",1, 2, 3},{"b"})); 
Show(wrap({"d",1, 2, 3},{"d"}));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;doesn't give the correct results for the 2nd call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But this works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Show(wrap({"d",1, 2, 3},{"d"}));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which would suggest that you shouldn't need to throw evals all over the place.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue is that the 1st call to the function works, and subsequent calls fail; which is very strange.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 08:17:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Map-Value-function-Inconsistent-results-for-subsequent-calls/m-p/515404#M74206</guid>
      <dc:creator>David_Burnham</dc:creator>
      <dc:date>2022-06-29T08:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: Map Value function: Wrong results for different characters</title>
      <link>https://community.jmp.com/t5/Discussions/Map-Value-function-Inconsistent-results-for-subsequent-calls/m-p/515410#M74207</link>
      <description>&lt;P&gt;Thanks for your reply. As you have said the first call works, the subsequent calls fail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have called our JMP support about this problem which has given this issue to its technical support team. If I get any news to that I will post it here.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 08:36:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Map-Value-function-Inconsistent-results-for-subsequent-calls/m-p/515410#M74207</guid>
      <dc:creator>ThomasDickel</dc:creator>
      <dc:date>2022-06-29T08:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: Map Value function: Wrong results for different characters</title>
      <link>https://community.jmp.com/t5/Discussions/Map-Value-function-Inconsistent-results-for-subsequent-calls/m-p/516228#M74279</link>
      <description>&lt;P&gt;The JMP support has answered me, it may be a defect which I have found.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Their support gave me the following solution to my original problem to remove unneeded items from a list using the Associative Array function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;filtered list = {"b", 1, 2, 3};
na_list = {"b"};
result = Associative Array(filtered list) &amp;lt;&amp;lt; Remove(Associative Array(na_list)) &amp;lt;&amp;lt; Get Keys; // {1, 2, 3}&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Jun 2022 14:28:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Map-Value-function-Inconsistent-results-for-subsequent-calls/m-p/516228#M74279</guid>
      <dc:creator>ThomasDickel</dc:creator>
      <dc:date>2022-06-30T14:28:18Z</dc:date>
    </item>
  </channel>
</rss>

