<?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 any way to create a multi-layer array? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-create-a-multi-layer-array/m-p/523673#M74841</link>
    <description>&lt;P&gt;Unfortunately JMP does not offer a &lt;CODE class=" language-jsl"&gt;zip()&lt;/CODE&gt; function for lists, but you can easily make one as a solution to your first item:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;zip = Function( {list a, list b},
	{zipped, i},
	zipped = {};
	Summation( i = 1, Min( Length( list a ), Length( list b ) ),
		zipped[i] = Eval List( {list a[i], list b[i]} );
		0
	);
	zipped
);

EX = Associative Array( {"Blue", "Green", "Red"}, zip( {1, 2, 3}, {"Bear", "Gecko", "Rabbit"} ) );
Show( ex )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;For your second item, see the function &lt;CODE class=" language-jsl"&gt;Name Expr()&lt;/CODE&gt; -- it should do what you want.&amp;nbsp; Note however that due to limitations of the JSL parser, you will have to first set a temporary variable for the function to land in, then call from that temporary variable.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;zip = Function( {list a, list b},
	{zipped, i},
	zipped = {};
	Summation( i = 1, Min( Length( list a ), Length( list b ) ),
		zipped[i] = Eval List( {list a[i], list b[i]} );
		0
	);
	zipped
);

EX = [=&amp;gt;];
EX["zip"] = Name Expr( zip );

func = ex["zip"];
Show( func( {1, 2, 3}, {"Bear", "Gecko", "Rabbit"} ) )&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 20 Jul 2022 04:52:10 GMT</pubDate>
    <dc:creator>ErraticAttack</dc:creator>
    <dc:date>2022-07-20T04:52:10Z</dc:date>
    <item>
      <title>Is there any way to create a multi-layer array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-create-a-multi-layer-array/m-p/523649#M74840</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) I'm trying to create a multilayer array where one key, gets multiple layers. Is there any way to do this. For example, my jsl should look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EX = Associative Array( {"Blue", "Green", "Red"}, {1, 2, 3}, {"Bear", "Gecko", "Rabbit"} );&lt;/P&gt;&lt;P&gt;I'm trying to get it so that if I select "Blue", I get both 1 and "Bear".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Is there any way for an array to map for a function. For example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EX = Associative Array( {"Blue", "Green"}, {functionA, functionB} );&lt;/P&gt;&lt;P&gt;Is there a way that the value returned triggers a function? I've tried and the values I get are in terms of string i.e if I select "Blue", I get the string "functionA" instead of it executing functionA.&amp;nbsp;&lt;/P&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 17:04:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-create-a-multi-layer-array/m-p/523649#M74840</guid>
      <dc:creator>PowerOx327</dc:creator>
      <dc:date>2023-06-09T17:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to create a multi-layer array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-create-a-multi-layer-array/m-p/523673#M74841</link>
      <description>&lt;P&gt;Unfortunately JMP does not offer a &lt;CODE class=" language-jsl"&gt;zip()&lt;/CODE&gt; function for lists, but you can easily make one as a solution to your first item:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;zip = Function( {list a, list b},
	{zipped, i},
	zipped = {};
	Summation( i = 1, Min( Length( list a ), Length( list b ) ),
		zipped[i] = Eval List( {list a[i], list b[i]} );
		0
	);
	zipped
);

EX = Associative Array( {"Blue", "Green", "Red"}, zip( {1, 2, 3}, {"Bear", "Gecko", "Rabbit"} ) );
Show( ex )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;For your second item, see the function &lt;CODE class=" language-jsl"&gt;Name Expr()&lt;/CODE&gt; -- it should do what you want.&amp;nbsp; Note however that due to limitations of the JSL parser, you will have to first set a temporary variable for the function to land in, then call from that temporary variable.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;zip = Function( {list a, list b},
	{zipped, i},
	zipped = {};
	Summation( i = 1, Min( Length( list a ), Length( list b ) ),
		zipped[i] = Eval List( {list a[i], list b[i]} );
		0
	);
	zipped
);

EX = [=&amp;gt;];
EX["zip"] = Name Expr( zip );

func = ex["zip"];
Show( func( {1, 2, 3}, {"Bear", "Gecko", "Rabbit"} ) )&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Jul 2022 04:52:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-create-a-multi-layer-array/m-p/523673#M74841</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2022-07-20T04:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to create a multi-layer array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-create-a-multi-layer-array/m-p/523678#M74842</link>
      <description>&lt;P&gt;Just another way to implement would be the following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// nested structure
EX = Associative Array( {"Blue", "Green", "Red"}, {{1, "Bear"}, {2, , "Gecko"}, {3, "Rabbit"}} );
Show( EX["Blue"] );

// Function example
myadd = Function( {op1, op2},
	op1 + op2
);
mymult = Function( {op1, op2},
	op1 * op2
);

func_aa = Associative Array( {"add", "mult"}, {myadd, mymult} );
myfunc = func_aa["add"];
Show( myfunc( 1, 2 ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Jul 2022 05:10:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-create-a-multi-layer-array/m-p/523678#M74842</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2022-07-20T05:10:27Z</dc:date>
    </item>
  </channel>
</rss>

