Roger's confidence that (a=: 100 (2}) a) is the best way is due to his
knowledge that J has special support for this construct, provided the same
name (viz. a) is used on both sides of the copula. Then it actually does
in-place updating (even though, at face value, J syntax does not permit
such a thing).

See the details at: http://www.jsoftware.com/jwiki/Vocabulary/curlyrt#dyadic
...down at the bottom under the heading: "Use These Combinations".

All this is advanced stuff for a beginner. Considerations like those raised
in this thread doubtless made Devon McCormick omit Amend } from his
"Minimal Beginning J" proposal (7 days ago, thread: "J Kernel"), in favor
of using }. and {. as Sebastian proposed.

On Mon, Sep 8, 2014 at 4:51 PM, Jose Mario Quintana <
jose.mario.quint...@gmail.com> wrote:

> Linda wrote:
> "
> The verb is amend and the main issue is that you must separate 100 and 2 or
> they become the list 100 2
> "
>
> Actually, amend (}) is an adverb and the verb is (2}).
>
> Roger wrote:
> "
>    a=: 100 (2}) a
> "
>
> The form that Roger gave makes that apparent:
>
>    test=. 2}
>    type'test'
> ┌────┐
> │verb│
> └────┘
>
>
>
>
> On Mon, Sep 8, 2014 at 11:13 AM, Linda Alvord <lindaalv...@verizon.net>
> wrote:
>
> > The verb is amend and the main issue is that you must separate  100 and 2
> > or
> > they become the list 100 2
> >
> >       100 (2)} A=.i.5
> > 0 1 100 3 4
> >
> >       (100) 2} A=.i.5
> > 0 1 100 3 4
> >
> >
> > Linda
> >
> > -----Original Message-----
> > From: programming-boun...@forums.jsoftware.com
> > [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Roger Hui
> > Sent: Monday, September 08, 2014 10:21 AM
> > To: Programming forum
> > Subject: Re: [Jprogramming] Replace one item of a list
> >
> >    a=: i.5
> >    a
> > 0 1 2 3 4
> >    a=: 100 (2}) a
> >    a
> > 0 1 100 3 4
> >
> >
> >
> > On Mon, Sep 8, 2014 at 7:18 AM, Sebastian <seb_fo...@arcor.de> wrote:
> >
> > > Hi,
> > >
> > > What is actually the best practice to replace one item of a list?
> > >
> > > The only way I know feels a bit complicated:
> > >
> > > a =: i. 5
> > > 0 1 2 3 4
> > >
> > >
> > >
> > > (2 {. a), 100, (3 }. a)
> > >
> > > 0 1 100 3 4
> > >
> > >
> > >
> > > Best regards,
> > >
> > > Sebastian
> > > ----------------------------------------------------------------------
> > > For information about J forums see http://www.jsoftware.com/forums.htm
> > >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to