Replicate: Difference between revisions

Jump to navigation Jump to search
57 bytes removed ,  09:59, 13 March 2020
no edit summary
(Created page with "{{Built-ins|Replicate|/|⌿}}, or '''Copy''' (<source lang=j inline>#</source>) in J, is a dyadic function or monadic operator that copies each element of the...")
 
No edit summary
Line 1: Line 1:
{{Built-ins|Replicate|/|⌿}}, or '''Copy''' (<source lang=j inline>#</source>) in [[J]], is a [[dyadic function]] or [[monadic operator]] that copies each [[element]] of the right [[argument]] a given number of times, ordering the copies along a specified [[axis]]. Typically <source lang=apl inline>/</source> is called Replicate while <source lang=apl inline>⌿</source> is called "Replicate First" or an equivalent. Replicate is a widely-accepted extension of the function '''Compress''', which requires the number of copies to be [[Boolean]]: each element is either retained (1 copy) or discarded (0 copies). Replicate with a Boolean left argument or [[operand]] may still be called "Compress".
{{Built-ins|Replicate|/|⌿}}, or '''Copy''' (<source lang=j inline>#</source>) in [[J]], is a [[dyadic function]] or [[monadic operator]] that copies each [[element]] of the right [[argument]] a given number of times, ordering the copies along a specified [[axis]]. Typically <source lang=apl inline>/</source> is called Replicate while <source lang=apl inline>⌿</source> is called "Replicate First" or an equivalent. Replicate is a widely-accepted extension of the function '''Compress''', which requires the number of copies to be [[Boolean]]: each element is either retained (1 copy) or discarded (0 copies). Replicate with a Boolean left argument or [[operand]] may still be called "Compress".


Replicate is usually associated with [[Expand]] (<source lang=apl inline>\</source>), and the two functions are related to [[Mask]] and [[Mesh]]. It is also closely related to the [[Indices]] function. It shares a [[glyph]] with [[Reduce]] even though Replicate is naturally a [[function]] and Reduce must be an [[operator]]. This incongruity is occasionally resolved by making Replicate an operator itself, and more often by checking the object to the left of a slash and treating the slash as Replicate if it is an array and as Reduce if it is a [[function]].
Replicate is usually associated with [[Expand]] (<source lang=apl inline>\</source>), and the two functions are related to [[Mask]] and [[Mesh]]. It is also closely related to the [[Indices]] function. It shares a [[glyph]] with [[Reduce]] even though Replicate is naturally a [[function]] and Reduce must be an [[operator]]. This incongruity is occasionally resolved by making Replicate an operator itself, and more often by [[function-operator overloading]] allowing both syntactic elements to coexist.


Outside of APL, [[wikipedia:filter (higher-order function)|filter]] typically provides the functionality of Compress, while Replicate has no common equivalent.
Outside of APL, [[wikipedia:filter (higher-order function)|filter]] typically provides the functionality of Compress, while Replicate has no common equivalent.

Navigation menu