Raul wrote:
"
For example:
amend=: 0&{::`(1&{::)`(2&{::)}
amend 0;2 3 5;7#9
9 9 0 0 9 0 9
"
Actually,
JVERSION
Installer: j602a_win.exe
Engine: j701/2011-01-10/11:25
Library: 6.02.023
amend=: 0&{::`(1&{::)`(2&{::)}
amend 0;2 3 5;7#9
|rank error: amend
| amend 0;2 3 5;7#9
|[-3]
However,
amend=. _: 0&{::@]`(1&{::@])`(2&{::@])} ]
amend 0;2 3 5;7#9
9 9 0 0 9 0 9
I use a slight variation of this verb occasionally; yet, I find the forms
<@:v N} ] and v N} ] extremelly useful for writing tacitly (and I write
tacitly all the time).
On Sun, Jul 6, 2014 at 6:42 AM, Raul Miller <[email protected]> wrote:
> I would agree that amend is seldom useful in much the same way that
> computers are seldom useful. That is: it depends on what you mean by
> "seldom" (and, for that matter, "useful").
>
> Generally speaking, } is one of the less common characters that I use
> when I write in J, but I do use it.
>
> Also, in addition to the very fine 0:`[`]} which behaves something like
> this:
>
> 2 3 5 0:`[`]} 7#9
> 9 9 0 0 9 0 9
>
> (Aside: note that in the above expression 2 3 5 is a word, and 0: is a
> separate word. Try ;:'2 3 5 0:`[`]} 7#9' if you want proof.)
>
> ... in addition to that approach, you can also arrange so that all
> arguments are given in an argument list, if you use
> 0&{::`(1&{::)`(2&{::)}
>
> For example:
> amend=: 0&{::`(1&{::)`(2&{::)}
> amend 0;2 3 5;7#9
> 9 9 0 0 9 0 9
>
> But, as with everything, whether this is a good thing or not depends
> on what you are trying to do...
>
> Which leads back to the question: what are you trying to do?
>
> Thanks,
>
> --
> Raul
>
> On 7/6/14, Ric Sherlock <[email protected]> wrote:
> > I don't agree that Amend is seldom useful. I do agree that it isn't the
> > easiest thing to get your head around (perhaps why you have found other
> > ways to getting stuff done).
> >
> > Aai has shown how to tacitly use Amend so it seems that 13 : is not smart
> > enough to give you a tacit equivalent. I suspect the reason Amend has
> been
> > defined as an adverb is that it requires 3 arguments: the array to amend,
> > the indicies to amend, the replacement data. Compare that to From which
> > only requires 2 bits of info (the array, the indicies).
> >
> >
> >
> > On Sun, Jul 6, 2014 at 7:53 PM, Ian Clark <[email protected]> wrote:
> >
> >> I think Erling is quite right, if you take what he says literally:
> "Amend
> >> is seldom useful for indexed replacement when you write tacit J".
> >>
> >> I'd go further and say "Amend is seldom useful." Period. I write a lot
> of
> >> J
> >> code and I hardly ever use it.
> >>
> >> To someone coming from C (say), this cries out for explanation. In C,
> just
> >> about everything is done by keyhole surgery, i.e. by tinkering with
> >> whatever happens to be at the end of a pointer (read: index). In J, just
> >> about nothing is done that way.
> >>
> >> Let me give an example. Suppose I want to write a verb to zero the x'th
> >> element of a list y ...
> >> I can easily write it as an explicit verb:
> >>
> >> zero=: 4 : '0 x} y'
> >> 3 zero i.6
> >> 0 1 2 0 4 5
> >>
> >> But "13 :" refuses to give me an equivalent tacit verb ...
> >>
> >> 13 : '0 x}y'
> >> 4 : '0 x}y'
> >>
> >> Is this just a shortcoming of "13 :" ? Does anyone know a "nice" tacit
> >> equivalent? I don't.
> >>
> >> Contrast this with what happens if I switch round 0 and x (...which
> gives
> >> me a verb to replace the first element of a list y with x). In this case
> >> "13 :" does deliver me a nice simple tacit equivalent ...
> >>
> >> 13 : 'x 0}y'
> >> 0}
> >>
> >> So why doesn't 13 : '0 x}y' do something equally as nice? It's all
> >> explained in http://www.jsoftware.com/jwiki/Vocabulary/curlyrt#dyadic .
> >> But
> >> that doesn't really explain to a newcomer why Amend was designed as an
> >> adverb:
> >> x m} y
> >> with (index) m as an *operand*, not an *argument*.
> >>
> >> Yes, I can write a tacit verb to zero the x'th element of list y ...
> >>
> >> zero2=: 13 : 'y * y~:x'
> >> 3 zero2 i.6
> >> 0 1 2 0 4 5
> >> zero2
> >> ] * ~:
> >>
> >> ... but not by using Amend, which is quite simply not useful in that
> role.
> >> Though I'm not claiming it can't be done - in fact there's a worked
> >> example
> >> in: http://www.jsoftware.com/jwiki/Vocabulary/curlyrt#dyadic under
> "More
> >> Information". But I wouldn't call it "nice".
> >>
> >> This illustrates the J approach to programming:
> >> http://www.jsoftware.com/jwiki/Vocabulary/Loopless -and how it
> contrasts
> >> with the C approach. Henry would explain it far better than I can, but
> >> he's
> >> busy.
> >>
> >> IanClark
> >>
> >>
> >> On Sat, Jul 5, 2014 at 8:59 PM, Erling Hellenäs <
> [email protected]>
> >> wrote:
> >>
> >> > Hi all !
> >> >
> >> > When you write tacit code, the index m used by Amend, syntax
> description
> >> > x m} y, is a constant?
> >> > Normally you have a variable you want to use for indexing? This means
> >> > Amend is seldom useful for indexed replacement when you write tacit J?
> >> > Are there any descriptions of nice ways to do indexed replacement in
> >> tacit
> >> > J?
> >> > As with Amend, the result has to be a new variable, of course.
> >> >
> >> > Cheers,
> >> >
> >> > Erling Hellenäs
> >> >
> >> > ----------------------------------------------------------------------
> >> > 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