Replicate: Difference between revisions

Jump to navigation Jump to search
879 bytes added ,  11:36, 13 March 2020
→‎History: NARS and APL2 negative number handling is different
(→‎History: A+, J, K)
(→‎History: NARS and APL2 negative number handling is different)
Line 59: Line 59:
Compress was described in [[A Programming Language]], where it was written with the symbols <math>/</math> and <math>/\!\!/</math>. In [[Iverson notation]] compression was particularly important because [[Take]] and [[Drop]] could be performed only by compression with a [[prefix]] or [[suffix]] vector. It was included in [[APL\360]], which changed the doubled slash to a barred slash <source lang=apl inline>⌿</source>, and allowed a [[specified axis]] and [[singleton extension]] on both sides (very briefly, singleton extension was allowed only for the right argument<ref>Falkoff, A.D., and K.E. Iverson, "[http://keiapl.org/archive/APL360_UsersMan_Aug1968.pdf APL\360 User's Manual]". IBM, August 1968.</ref>). The APL\360 definition continued to be included in APLs unchanged until 1980.
Compress was described in [[A Programming Language]], where it was written with the symbols <math>/</math> and <math>/\!\!/</math>. In [[Iverson notation]] compression was particularly important because [[Take]] and [[Drop]] could be performed only by compression with a [[prefix]] or [[suffix]] vector. It was included in [[APL\360]], which changed the doubled slash to a barred slash <source lang=apl inline>⌿</source>, and allowed a [[specified axis]] and [[singleton extension]] on both sides (very briefly, singleton extension was allowed only for the right argument<ref>Falkoff, A.D., and K.E. Iverson, "[http://keiapl.org/archive/APL360_UsersMan_Aug1968.pdf APL\360 User's Manual]". IBM, August 1968.</ref>). The APL\360 definition continued to be included in APLs unchanged until 1980.


In 1980, [[Bob Bernecky]] introduced the extension Replicate to [[SHARP APL]]: he allowed an operand (since SHARP's Replicate is an operator) consisting of non-negative integers rather than just [[Boolean]]s to indicate the number of times to copy.<ref>[[Bob Bernecky|Bernecky, Bob]]. SATN-34: Replication. [[IPSA]]. 1980-08-15.</ref> This extension was implemented in [[NARS]] in 1981, along with further extensions: a similar change to [[Expand]], and the extension allowing negative integers to indicate [[fill element]]s. Both extensions were quickly adopted by the APL community, and were included in new nested APLs such as [[Dyalog APL]] and [[APL2]], and later the [[ISO/IEC 13751:2001]] standard.
In 1980, [[Bob Bernecky]] introduced the extension Replicate to [[SHARP APL]]: he allowed an operand (since SHARP's Replicate is an operator) consisting of non-negative integers rather than just [[Boolean]]s to indicate the number of times to copy.<ref>[[Bob Bernecky|Bernecky, Bob]]. SATN-34: Replication. [[IPSA]]. 1980-08-15.</ref> This extension was rapidly and widely adopted, starting with [[NARS]] in 1981, and is now a feature of the [[ISO/IEC 13751:2001]] standard.
 
Two extensions to allow negative numbers in the left argument have been introduced, in each case specifying that the negative of a number indicates that many [[fill element]]s should appear in the result. In 1981 [[NARS]] specified that these fill elements replace the corresponding right argument element, so that the lengths of the left and right arguments are always equal, and extended [[Expand]] similarly. [[APL2]], in 1984, made the opposite choice, so that the length of the right argument along the specified axis is equal to the number of non-negative elements on the left. [[APL2]] also loosened the [[conformability]] requirements further than simply allowing [[singleton extension]]: it allowed a right argument with length 1 along the replication axis to be extended. [[Dyalog APL]], created before APL2, adopted the [[NARS]] definition for negative elements and later also the APL2 conformability extension. Later [[APLX]] took advantage of the fact that the two negative number extensions can be distinguished by the length of the left argument, and implemented every NARS and APL2 extension.


[[A+]] and [[J]] modified Replicate to fit [[leading axis theory]]. Rather than allow Replicate to operate on any axis they have only one Replicate function (in A+, <source lang=apl inline>/</source>; in J, <source lang=j inline>#</source>) which works on the first axis—it copies [[major cell]]s rather than elements. Both languages rejected the [[NARS]] extension to negative left arguments, but J introduced its own system to add [[fill element]]s by allowing [[complex number]]s in the left argument, and removed the [[Expand]] function entirely. [[Arthur Whitney]] went on to make a more radical change in [[K]], removing Replicate entirely in favor of [[Where]].
[[A+]] and [[J]] modified Replicate to fit [[leading axis theory]]. Rather than allow Replicate to operate on any axis they have only one Replicate function (in A+, <source lang=apl inline>/</source>; in J, <source lang=j inline>#</source>) which works on the first axis—it copies [[major cell]]s rather than elements. Both languages rejected the [[NARS]] extension to negative left arguments, but J introduced its own system to add [[fill element]]s by allowing [[complex number]]s in the left argument, and removed the [[Expand]] function entirely. [[Arthur Whitney]] went on to make a more radical change in [[K]], removing Replicate entirely in favor of [[Where]].

Navigation menu