Unique: Difference between revisions

Jump to navigation Jump to search
50 bytes removed ,  12:57, 23 November 2023
Simpler fix for length-1 case
(update model for unique to work with all cases of inputs)
(Simpler fix for length-1 case)
 
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 ← {⍬≡⍴⍵:,⍵ ⋄ 1≥≢⍵:⍵ ⋄ ↑⊃∪⍨/⌽⊂¨⊂⍤¯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 ← {⍬≡⍴⍵:,⍵ ⋄ 1≥≢⍵:⍵ ⋄ ↑⊃{⍺,(∧/⍺≢¨⍵)/⍵}⍨/⌽⊂¨⊂⍤¯1⊢1/⍵}
m ← {0=≢⍵:⍵ ⋄ ↑,⊃{⍺,(∧/⍺≢¨⍵)/⍵}⍨/⌽⊂¨⊂⍤¯1⊢⍵}
</syntaxhighlight>
</syntaxhighlight>
{{Works in|[[Dyalog APL]]}}
{{Works in|[[Dyalog APL]]}}

Navigation menu