Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Based on "Kind of like Map, except with a variable number of arguments." I think you might be looking for <code>Apply</code> to level 1. This is done with:</p> <pre><code>Apply[function, array, {1}] </code></pre> <p>or the shorthand:</p> <pre><code>function @@@ array </code></pre> <p>Here is what it does:</p> <pre><code>array = {{1, 2, 3}, {a, b, c}, {Pi, Sin, Tan}}; action @@@ array </code></pre> <pre><b> {action[1, 2, 3], action[a, b, c], action[Pi, Sin, Tan]} </b></pre> <hr> <p>The terminology I used above could be misleading, and limits the power of <code>Apply</code>. The expression to which you apply <code>action</code> does not need to be a rectangular array. It does not even need to be a <code>List</code>: <code>{...}</code> or have its elements be lists. Here is an example incorporating these possibilities:</p> <pre><code>args = {1, 2} | f[a, b, c] | {Pi}; action @@@ args </code></pre> <pre><b> action[1, 2] | action[a, b, c] | action[Pi] </b></pre> <ul> <li><code>args</code> is not a <code>List</code> but a set of <code>Alternatives</code></li> <li>the number of arguments passed to <code>action</code> varies</li> <li>one of the elements of <code>args</code> has head <code>f</code></li> </ul> <p>Observe that:</p> <ul> <li><code>action</code> replaces the head of each element of <code>args</code>, whatever it may be.</li> <li>The head of <code>args</code> is preserved in the output, in this case <code>Alternatives</code> (short form: <code>a | b | c</code>)</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload