Commute-Duplicate: Difference between revisions

From NARS2000
Jump to navigationJump to search
No edit summary
No edit summary
 
Line 37: Line 37:
<p>For example:</p>
<p>For example:</p>


<apll>
<apll><pre>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;×⍨⍳5 ⍝ squares <br/>
      ×⍨⍳5 ⍝ squares
1 4 9 16 25<br/>
1 4 9 16 25
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;∘.=⍨⍳4 ⍝ Identity matrix<br />
      ∘.=⍨⍳4 ⍝ Identity matrix
1 0 0 0<br />
1 0 0 0
0 1 0 0<br />
0 1 0 0
0 0 1 0<br />
0 0 1 0
0 0 0 1<br />
0 0 0 1
</apll>
</pre></apll>


<apll>
<apll><pre>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2*⍨⍳5 ⍝ squares <br/>
      2*⍨⍳5 ⍝ squares
1 4 9 16 25<br/>
1 4 9 16 25
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;√+/2*⍨6 2⍴3 4, 5 12, 8 15, 7 24, 20 21, 12 35 ⍝ Pythagorean hypotenuses<br />
      √+/2*⍨6 2⍴3 4, 5 12, 8 15, 7 24, 20 21, 12 35 ⍝ Pythagorean hypotenuses
5 13 17 25 29 37<br />
5 13 17 25 29 37
</apll>
</pre></apll>

Latest revision as of 23:41, 15 April 2018

Duplicate: Z←f⍨ R      returns R f R.
Commute: Z←L f⍨ R returns R f L.
L and R are arrays.
f is a function.

For example:

      ×⍨⍳5 ⍝ squares
1 4 9 16 25
      ∘.=⍨⍳4 ⍝ Identity matrix
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
      2*⍨⍳5 ⍝ squares
1 4 9 16 25
      √+/2*⍨6 2⍴3 4, 5 12, 8 15, 7 24, 20 21, 12 35 ⍝ Pythagorean hypotenuses
5 13 17 25 29 37