Key: Difference between revisions

Jump to navigation Jump to search
2,309 bytes added ,  16 April
History, and J and Kap documentation links
m (Text replacement - "<source" to "<syntaxhighlight")
Tags: Mobile edit Mobile web edit
(History, and J and Kap documentation links)
 
Line 81: Line 81:
</syntaxhighlight>
</syntaxhighlight>
If there are a large number of unique values, the repeated updating of the accumulating <syntaxhighlight lang=apl inline>keys</syntaxhighlight> variable can be an issue in itself.
If there are a large number of unique values, the repeated updating of the accumulating <syntaxhighlight lang=apl inline>keys</syntaxhighlight> variable can be an issue in itself.
== History ==
A key operator was first defined in [[J]] by 1990. J's implementer [[Roger Hui]] had written a J model taking a monadic function operand and two arguments in January following a discussion at [[I.P. Sharp Associates]]; he mentioned that such an operator had been proposed in the past by himself as well as [[Joey Tuttle]] and [[Bob Bernecky]].<ref>[[Roger Hui]]. [https://code.jsoftware.com/wiki/Essays/Key Essays/Key]. "History".</ref>
Hui also implemented the operator in [[Dyalog APL 14.0]], released in 2014. This version added the left argument to the operand function call based on experience with J, and also defined the monadic case, which in J had been defined as Oblique, calling the function on diagonals of an argument matrix. This definition was adopted by Dyalog-like dialects including [[ngn/apl]], [[dzaima/APL]] (with changes), and [[April]]. In 2023, [[Henry Rich]] added a new key primitive <syntaxhighlight lang=j inline>/..</syntaxhighlight> to J that also passes the unique value as the left argument (however, calling the derived function monadically was not defined).
Other variations on Key have been implemented. Since 2023 [[Kap]] defines a primitive function <syntaxhighlight lang=apl inline>⌸</syntaxhighlight> that functions like Dyalog's <syntaxhighlight lang=apl inline>{⍺⍵}⌸</syntaxhighlight>. [[Dyalog APL Vision]] defines an extension to Key when the operand is an array. The operand defines a vocabulary, so that result elements correspond to cells of the operand, and these elements contain either a list of indices where that value was found (if monadic), or right argument cells corresponding to positions where it was found in the left argument (if dyadic). The monadic form is similar to [[K|K3]]'s [[Group (K)|Group]], except the list of keys is specified explicitly rather than being taken from the unique values of the argument.


== External links ==
== External links ==
Line 87: Line 94:
=== Documentation ===
=== Documentation ===
* [https://help.dyalog.com/latest/Content/Language/Primitive%20Operators/Key.htm Dyalog]
* [https://help.dyalog.com/latest/Content/Language/Primitive%20Operators/Key.htm Dyalog]
* [https://kapdemo.dhsdevelopments.com/reference.html#_key Kap] (a primitive function variation)
* J [https://code.jsoftware.com/wiki/Vocabulary/slashdot#dyadic NuVoc] (<syntaxhighlight lang=j inline>/.</syntaxhighlight> and <syntaxhighlight lang=j inline>/..</syntaxhighlight>), [https://code.jsoftware.com/wiki/Vocabulary/slashdot#dyadic Dictionary] (<syntaxhighlight lang=j inline>/.</syntaxhighlight> only)


{{APL built-ins}}[[Category:Primitive operators]]
{{APL built-ins}}[[Category:Primitive operators]]

Navigation menu