Unique: Difference between revisions

Jump to navigation Jump to search
5 bytes removed ,  12:57, 23 November 2023
Simpler fix for length-1 case
(→‎APL model: Synthesize previous versions, with some extra explanation)
(Simpler fix for length-1 case)
 
(2 intermediate revisions by 2 users 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