Indices: Difference between revisions

Jump to navigation Jump to search
m (Text replacement - "Kx Systems" to "Kx Systems")
Line 68: Line 68:
[[Idiom]]s with similar behavior to Indices were widely used in APL long before it was made into a primitive. For example, the [[FinnAPL idiom library]], first presented in 1984, lists <syntaxhighlight lang=apl inline>X/⍳⍴X</syntaxhighlight> as "594. Indices of ones in logical vector X".
[[Idiom]]s with similar behavior to Indices were widely used in APL long before it was made into a primitive. For example, the [[FinnAPL idiom library]], first presented in 1984, lists <syntaxhighlight lang=apl inline>X/⍳⍴X</syntaxhighlight> as "594. Indices of ones in logical vector X".


Where (<code>&</code>) with a Boolean argument was present in [[K]] by K2 in 1996,<ref>Kx Systems. [http://web.archive.org/web/20041022042401/http://www.kx.com/technical/documents/kusrlite.pdf "K User Manual"]. 1998.</ref> and extended to non-negative integers by K4 in 2000. It was added to [[J]] for the domain of non-negative integer vectors as Indices (<syntaxhighlight lang=j inline>I.</syntaxhighlight>) in release 5.02 (2003), introducing the pairing of Indices and [[Interval Index]] now used in APL.<ref>Jsoftware. [https://www.jsoftware.com/docs/archive/release/ifb.htm "I. Implements ''Indices'']. 2003.</ref>
Where (<code>&</code>) with a Boolean argument was present in [[K]] by K2 in 1996,<ref>[[Kx Systems]]. [http://web.archive.org/web/20041022042401/http://www.kx.com/technical/documents/kusrlite.pdf "K User Manual"]. 1998.</ref> and extended to non-negative integers by K4 in 2000. It was added to [[J]] for the domain of non-negative integer vectors as Indices (<syntaxhighlight lang=j inline>I.</syntaxhighlight>) in release 5.02 (2003), introducing the pairing of Indices and [[Interval Index]] now used in APL.<ref>Jsoftware. [https://www.jsoftware.com/docs/archive/release/ifb.htm "I. Implements ''Indices'']. 2003.</ref>


Indices (<syntaxhighlight lang=apl inline>⍸</syntaxhighlight>) was first introduced to APL, and the [[nested array model]], by [[NARS2000]]. Originally defined only for vectors, the generalised definition <syntaxhighlight lang=apl inline>(,R)/,⍳⍴1/R</syntaxhighlight> was introduced in about 2013 after some experimentation with alternatives.<ref>NARS2000 Wiki. [http://wiki.nars2000.org/index.php?title=Indices&direction=next&oldid=863 Indices]. Old revision: 2013-05-26.</ref> Where (<syntaxhighlight lang=apl inline>⍸</syntaxhighlight>) was added to [[Dyalog APL 16.0]] (June 2017), with the nearly-identical definition <syntaxhighlight lang=apl inline>{(,⍵)⌿,⍳⍴⍵}</syntaxhighlight>, but also with the restriction that the argument be Boolean. This restriction that was lifted to allow non-negative integers in [[Dyalog APL 18.0|18.0]] (2020). For a [[scalar]] <syntaxhighlight lang=apl inline>I</syntaxhighlight>, Dyalog's definition gives <syntaxhighlight lang=apl inline>I⍴⊂⍬</syntaxhighlight> for <syntaxhighlight lang=apl inline>⍸I</syntaxhighlight>, while NARS2000 returned <syntaxhighlight lang=apl inline>I⍴1</syntaxhighlight>. By January 2018, NARS2000 switched to Dyalog's definition, removing the discrepancy for scalar arguments.
Indices (<syntaxhighlight lang=apl inline>⍸</syntaxhighlight>) was first introduced to APL, and the [[nested array model]], by [[NARS2000]]. Originally defined only for vectors, the generalised definition <syntaxhighlight lang=apl inline>(,R)/,⍳⍴1/R</syntaxhighlight> was introduced in about 2013 after some experimentation with alternatives.<ref>NARS2000 Wiki. [http://wiki.nars2000.org/index.php?title=Indices&direction=next&oldid=863 Indices]. Old revision: 2013-05-26.</ref> Where (<syntaxhighlight lang=apl inline>⍸</syntaxhighlight>) was added to [[Dyalog APL 16.0]] (June 2017), with the nearly-identical definition <syntaxhighlight lang=apl inline>{(,⍵)⌿,⍳⍴⍵}</syntaxhighlight>, but also with the restriction that the argument be Boolean. This restriction that was lifted to allow non-negative integers in [[Dyalog APL 18.0|18.0]] (2020). For a [[scalar]] <syntaxhighlight lang=apl inline>I</syntaxhighlight>, Dyalog's definition gives <syntaxhighlight lang=apl inline>I⍴⊂⍬</syntaxhighlight> for <syntaxhighlight lang=apl inline>⍸I</syntaxhighlight>, while NARS2000 returned <syntaxhighlight lang=apl inline>I⍴1</syntaxhighlight>. By January 2018, NARS2000 switched to Dyalog's definition, removing the discrepancy for scalar arguments.