Talk:Unique

From APL Wiki
Revision as of 20:19, 4 October 2023 by Kamila Szewczyk (talk | contribs)
Jump to navigation Jump to search

APL models

This revision removes

VecUnique ← {
  u ← 0↑⍵
  u ⊣ {u∪←⍵}⍤¯1 ⊢1/⍵
}

along with an explanation of what it does; the new code is unexplained. Is there something wrong with this version? I think it's still good as a gentler introduction for those who aren't fluent in reductions.

There was an error in the later definition Unique ← {1/↑↑⌽∪/⌽⊂∘⊂⍤¯1⊢⍵}, which I believe is fixed by changing ⌽∪/⌽ to ∪⍨/⌽. And it's unable to handle length-zero arguments, but I would use {0=≢⍵:⍵ ⋄ 1/↑⊃∪⍨/⌽⊂∘⊂⍤¯1⊢⍵} rather than the complicated test that now handles all empty arrays.

The reduction is reversed to deal with tolerant comparison correctly. The new code gets this wrong; try on 1+⎕CT×5÷⍨⍳20 for instance.

I don't know if I'd say the new version is "suggested by Kamila Szewczyk" as it's similar in substance to the current code; regardless, Wiki contributions should not be attributed in text as that information is in the edit history.

--Marshall (talk) 14:29, 3 October 2023 (UTC)

Just read through this and I agree. Feel free to make the adjustments to the article as necessary.

Kamila Szewczyk (talk) 20:19, 4 October 2023 (UTC)