My own version looks like this: nameExists=: 0:"_ <: [: 4!:0 <^:(L. = 0:)
This handles enclosed names because I have a list of some common global names I sometimes check and this saves me an "each". On Mon, Aug 3, 2020 at 1:11 PM Henry Rich <henryhr...@gmail.com> wrote: > An undefined name is assumed to be a verb, so tally never gets > executed. I use > > ifdefined_z_ =: 0 <: [: 4!:0 < > > ifdefined 'a' > 0 > ifdefined 'ifdefined' > 1 > > Henry Rich > > > On 8/3/2020 12:52 PM, Brian Schott wrote: > > This thread hints at a problem I am having. > > In particular the link suggested by Henry > > https://code.jsoftware.com/wiki/Vocabulary/ErrorMessages#value > > > > My problem is that I want to detect an error caused by an undefined noun > > but my attempt does not produce the desired error using :: . > > For example in the example below, although `a` is undefined, I do not get > > the desired result, 0, from my verb `tally` when I execute `tally a`. > > How can I define tally to produce 0 for an undefined argument. Or how do > I > > detect an undefined argument, in general? I have considered using a try. > > ... catch. in an explicit definition, but to me that seems unnecessary. > > > > a > > |value error: a > > tally =: # :: 0: > > tally i. 4 > > 4 > > tally a > > tally a > > > > On Wed, Nov 6, 2019 at 5:11 AM Henry Rich <henryhr...@gmail.com> wrote: > > > >> https://code.jsoftware.com/wiki/Vocabulary/ErrorMessages#value > >> > >> Henry Rich > >> > >> On 11/6/2019 4:26 AM, Arnab Chakraborty wrote: > >>> Dear all, > >>> > >>> Here is a behavior that I noticed only recently, and it puzzles > me a > >>> lot: > >>> > >>> Let's say abc and xyz are not defined in my J session, and type > just > >> abc > >>> by itself in a line. Of course, I get a value error. But if I type > >>> > >>> xyz abc > >>> > >>> then J does not produce any error, but simply echos back what I have > >> typed! > >>> I expected that J would start executing from the right, encounter abc, > >> and > >>> produce a value error. If I now define abc (say abc=. 0), then > >>> > >>> xyz abc > >>> > >>> produces a value error (expected) about xyz. > >>> > >>> But why does J become silent in presence of multiple undefined symbols? > > > -- > This email has been checked for viruses by AVG. > https://www.avg.com > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Devon McCormick, CFA Quantitative Consultant ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm