I did indeed mean replacing an element by its index. It was just a general interest question, though. There are instances where I've had a boxed list representing some kind of object, and I've wanted to replace a box at a certain index with a new box with its contents applied to some monad.
On 23 November 2010 22:24, Raul Miller <[email protected]> wrote: > On Tue, Nov 23, 2010 at 5:05 PM, Justin Paston-Cooper > <[email protected]> wrote: >> What is a common phrase for replacing element n in an array a by >> itself applied to a monad m? > > Note that m is often used to refer to nouns rather than verbs, > (in explicit adverbs and conjunctions) so lets use M instead of m. > Also, 'a' is an english word, so let us use A instead of a. And, > for consistency and emphasis, let us use N in place of n. > > The most common phrase is: > M A > > Of course, this replaces all of A with the result of M, but > that is usually good practice. But this means that you > have to pull the conditional logic into the definition of M > which sometimes may be an issue. > > If A is numeric, you can use > A + (N=A) * (M A)-A > > Or, if you want a tacit version of that: > N (] - = * (- M)@]) A > > If A has only one dimension, you can use: > (M (N=A)#A) (I.N=A)} A > > That said, I just now noticed a response from Dan > Bron where he understood N to mean the index of > a value rather than the value itself. And that is > another possibility. > > I suppose the really correct approach, here, would be to ask > what problem you are trying to solve. This sort of question > (where you are focusing on an individual element of an array, > rather than the array itself) seems to suggest a problem where > perhaps a better approach could be available than the one you > are trying to apply. (Or, it would be if I were posing this kind > of question.) > > Thanks, > > -- > Raul > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
