Thanks. Pointing to the error messages was helpful. Linda -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Ian Clark Sent: Tuesday, July 08, 2014 8:52 AM To: [email protected] Subject: Re: [Jprogramming] Tacit J and indexed replacement
@Linda - the "domain error" is because you've defined h as: h=: 3 :'0 x } y' That should have been h=: 4 :'0 x } y' if you're going to call h dyadically. But I sympathize. Exactly this error catches me out all too often. Particularly when I've been using "13 :" If I was awarding the prize for the most unhelpful and time-wasting error message of all, it would go to "domain error". In this case it tricks you into looking for the cause inside the algorithm itself (which is of course what you're focussed on developing). It wouldn't be so bad if it merely said "you goofed". Look up "domain error" in http://www.jsoftware.com/jwiki/Vocabulary/ErrorMessages in particular: http://www.jsoftware.com/jwiki/Vocabulary/ErrorMessages#domainvalence It bends over backwards to alert you to this possible cause. The whole sorry business about monad vs. dyad is explained here: http://www.jsoftware.com/jwiki/Vocabulary/Valence I say "sorry business" because I'd like to see the terms "monad" and "dyad" banned -- sorry, "deprecated" -- in favor of "called monadically" and "called dyadically". It tricks even intermediate users into believing there are two different kinds of verb. Note to others: if we're going to have a discussion on this topic, I suggest we start a new thread, because it's nothing to do with Amend. On Tue, Jul 8, 2014 at 1:22 PM, Linda Alvord <[email protected]> wrote: > I'm comparing it to the post below it that says it is a verb. It struck > me as a peculiar inconsistency.'' > > Linda > > -----Original Message----- > From: [email protected] [mailto: > [email protected]] On Behalf Of Raul Miller > Sent: Tuesday, July 08, 2014 5:52 AM > To: [email protected] > Subject: Re: [Jprogramming] Tacit J and indexed replacement > > I think we have covered these issues with you before. Do you remember > why you should get that error? > > Thanks, > > -- > Raul > > On 7/8/14, Linda Alvord <[email protected]> wrote: > > And then! > > > > h=: 3 :'0 x } y' > > 4 5 h i.11 > > |domain error: h > > | 4 5 h i.11 > > > > Linda > > > > -----Original Message----- > > From: [email protected] > > [mailto:[email protected]] On BehalSSf Of Linda > > Alvord > > Sent: Tuesday, July 08, 2014 5:14 AM > > To: [email protected] > > Subject: Re: [Jprogramming] Tacit J and indexed replacement > > > > Ian's post was very early in this thread, but something has puzzled me > for a > > while as I tried to write a tacit version: > > > > f=: 13 :'0 x } y' > > 4 5 f i.11 > > 0 1 2 3 0 0 6 7 8 9 10 > > g=: 4 :'0 x } y' > > 4 5 g i.11 > > 0 1 2 3 0 0 6 7 8 9 10 > > > > f > > 4 : '0 x } y' > > g > > 4 : '0 x } y' > > > > 4!:0 <'f' > > 3 > > 4!:0 <'g' > > 3 > > > > Linda > > > > > > -----Original Message----- > > From: [email protected] > > [mailto:[email protected]] On Behalf Of Ian Clark > > Sent: Sunday, July 06, 2014 3:54 AM > > To: [email protected] > > Subject: Re: [Jprogramming] Tacit J and indexed replacement > > > > 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 > > ---------------------------------------------------------------------- > 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
