At: Difference between revisions

Jump to navigation Jump to search
815 bytes added ,  09:52, 27 April 2022
(correction for bools)
Line 2: Line 2:


== Description ==
== Description ==
At takes two operator arguments, and it has many overloads based on the types of its arguments.
At takes two operands, each of which can be an [[array]] or [[function]], with varying effect:
A call to At is of the form <source lang=apl inline>X(f@g)Y</source> where <source lang=apl inline>X</source> is optional.  
A call to At is of the form <source lang=apl inline>X(f@g)Y</source> where <source lang=apl inline>X</source> is optional.  
* <source lang=apl inline>g</source>  specifies the indices of the right argument that should be modified.
* <source lang=apl inline>g</source>  specifies the indices of the right argument that should be modified.
** '''Function''': Must apply to <source lang=apl inline>Y</source> , and return a boolean array with ones at positions that should be modified.
** '''Function''': Must apply monadically to <source lang=apl inline>Y</source>, and return a boolean array of the same shape as <source lang=apl inline>Y</source>, with ones at positions that should be amended.
** '''Array''': Specifies the indices directly. If this is a scalar, it is repeated as necessary.
** '''Array''': A [[vector]] (or [[scalar]]) of [[cell]] indices (of equal lengths) to amend. If the same index appears multiple times, the last amendment overrules any previous ones, meaning that amendments are not stacked. This is in contrast to [[modified assignment]] where multiple specifications of the same parts of the array will be processed sequentially.
* <source lang=apl inline>f</source> specifies what happens to the elements at those positions.
* <source lang=apl inline>f</source> specifies what happens to the elements at those positions.
** '''Function''': Applies to all the selected elements at once. If <source lang=apl inline>X</source> is given, then it is bound to this function (<source lang=apl inline>X∘f</source> ).
** '''Function''': Is applied once on an array whose [[major cell]]s are the selected cells. If <source lang=apl inline>X</source> is present, then it is bound to <source lang=apl inline>f</source> so <source lang=apl inline>X f@g Y</source> is equivalent to <source lang=apl inline>X∘f@g Y</source>.
** '''Array''': Replaces the selected elements.
** '''Array''': Replaces the selected elements and must either have the same shape as the array whose major cells are the selected cells, or be a scalar, which then replaces all selected cells.
Each possible [[derived function]] can be applied [[monadic]]ally or [[dyadic]]ally, except if the left operand (<source lang=apl inline>f</source>) is an array, in which case, only the monadic derived function is defined.


== Examples ==
== Examples ==

Navigation menu