Outer Product: Difference between revisions
Jump to navigation
Jump to search
m (Added prime number example) |
m (remove duplicated code) |
||
Line 32: | Line 32: | ||
For example, suppose we want to find duplicated elements in an non-[[nested array]]. Intuitively speaking, the easiest way to solve this problem is to compare each element of the array with all other elements, which is exactly what an outer product does. | For example, suppose we want to find duplicated elements in an non-[[nested array]]. Intuitively speaking, the easiest way to solve this problem is to compare each element of the array with all other elements, which is exactly what an outer product does. | ||
<source lang=apl> | <source lang=apl> | ||
x ← 1 2 3 2 | x ← 1 2 3 2 | ||
⎕ ← matrix ← x∘.=x ⍝ compare elements with each other using equal | ⎕ ← matrix ← x∘.=x ⍝ compare elements with each other using equal |