Unique: Difference between revisions

Jump to navigation Jump to search
2 bytes removed ,  12:57, 23 November 2023
Simpler fix for length-1 case
m (→‎APL model: Explicit version of the Union replacement)
(Simpler fix for length-1 case)
 
(One intermediate revision by one other user not shown)
Line 87: Line 87:
It is extended to empty, nested, and arbitrary rank inputs as follows:
It is extended to empty, nested, and arbitrary rank inputs as follows:
<syntaxhighlight lang=apl>
<syntaxhighlight lang=apl>
m ← {0=≢⍵:⍵ ⋄ ↑⊃∪⍨/⌽⊂¨⊂⍤¯1⊢1/⍵}
m ← {0=≢⍵:⍵ ⋄ ↑,⊃∪⍨/⌽⊂¨⊂⍤¯1⊢⍵}
</syntaxhighlight>
</syntaxhighlight>
{{Works in|[[Dyalog APL]]}}
{{Works in|[[Dyalog APL]]}}
Line 94: Line 94:
If modelling the primitive via Union is not desirable due to how similar these two primitives are, it is possible to replace this particular usage of union (not generally, as it relies on the right argument being scalar) as follows:
If modelling the primitive via Union is not desirable due to how similar these two primitives are, it is possible to replace this particular usage of union (not generally, as it relies on the right argument being scalar) as follows:
<syntaxhighlight lang=apl>
<syntaxhighlight lang=apl>
m ← {0=≢⍵:⍵ ⋄ ↑⊃{⍺,(∧/⍺≢¨⍵)/⍵}⍨/⌽⊂¨⊂⍤¯1⊢1/⍵}
m ← {0=≢⍵:⍵ ⋄ ↑,⊃{⍺,(∧/⍺≢¨⍵)/⍵}⍨/⌽⊂¨⊂⍤¯1⊢⍵}
</syntaxhighlight>
</syntaxhighlight>
{{Works in|[[Dyalog APL]]}}
{{Works in|[[Dyalog APL]]}}

Navigation menu