I'm totally fine with you writing up NuVoc entries, and using whatever
I've written here to fuel them.

Thanks,

-- 
Raul


On Sat, Jun 10, 2017 at 12:38 AM, Ian Clark <[email protected]> wrote:
> It's a nice point: is a noun "empty" because it has no atoms – or because
> it has no items?
>
> My appeal for "a reliable test for emptiness" was not an invitation to post
> code, but invite the community to reach a consensus on this, for inclusion
> in a proposed NuVoc page.
>
> I hadn't meant to divert the discussion away from what IMO is the topic:
> helping a beginner correctly handle an empty noun (and/or empty list).
>
> Speaking for myself, in the past I've used both Jasmin's and Raul's test of
> emptiness, depending whether I was coding a generalized utility, or solving
> a real-world problem. Which is not far off what Raul has just said.
>
> I guess my meaning of "empty" ought to be NuVoc's, which you can read in:
>    http://code.jsoftware.com/wiki/Vocabulary/Glossary#Empty
> …i.e. "no atoms".
>
> Does it matter?
>
> A newcomer to J might be forgiven for thinking it's "Much Ado About
> Nothing", as someone posted earlier. I'd disagree. It's fundamentally
> important – and I mean "fundamentally" – all about foundations – not just a
> long word for "very". Was it Knuth who first identified the "null case"
> (…did he call it?) as a large, important and massively wasteful class of
> bug? Older programmers will point me at a good reference.
>
> It follows that NuVoc ought to have a big bold answer to questions about
> empty nouns. It doesn't. (At least, not bold enough). As a newcomer I'd
> expect to find: Vocabulary/EmptyNouns or /EmptyLists in:
>    http://code.jsoftware.com/wiki/NuVoc#bottomrefs
>
> @Raul – if you're not going to write it, are you happy for me to do so,
> using what you've posted in this thread? It won't be for a week or two
> because I'm snowed under and I don't know why I'm volunteering for this.
> Out of embarrassment, maybe.
>
> Obligatory null-case joke (with apologies to Raul)…
>
> BANK MANAGER: Why did you write the IRS a check for $0-00?
>
> CUSTOMER: They said they needed it for the good of their system.
>
> BANK MANAGER: Whaddya think it's done to OUR system?
>
>
>
>
> On Fri, Jun 9, 2017 at 12:41 PM, Raul Miller <[email protected]> wrote:
>
>> I'm not sure I completely agree:
>>
>>    i. 1 0 1
>>    0 < # i. 1 0 1
>> 1
>>    0 < # 3
>> 1
>>
>> For the general case of emptiness, the reliable test would be 0 e. $
>>
>> That said, checking for zero items (or more than zero items) is often
>> quite convenient.
>>
>> Thanks,
>>
>> --
>> Raul
>>
>>
>> On Fri, Jun 9, 2017 at 7:36 AM, 'Pascal Jasmin' via Programming
>> <[email protected]> wrote:
>> > the reliable test for emptiness is (0 < #)
>> >
>> >
>> >
>> >
>> > ________________________________
>> > From: Ian Clark <[email protected]>
>> > To: [email protected]
>> > Sent: Thursday, June 8, 2017 11:15 PM
>> > Subject: Re: [Jprogramming] Empty lists?
>> >
>> >
>> >
>> > Henry, I absolutely agree.
>> >
>> > Only last night I was thinking NuVoc lacked an in-depth treatment of
>> empty
>> > lists (/tables) – and how it was a serious omission. (It does have
>> > Vocabulary/EmptyArguments --which overlaps slightly.)
>> >
>> > Devon's treatment fits the bill.
>> >
>> > Might also need a reliable test for emptiness, to discourage use of: if.
>> y
>> > -: '' do. …
>> >
>> > On Fri, Jun 9, 2017 at 3:44 AM, Henry Rich <[email protected]> wrote:
>> >
>> >> This is great - would you be willing to add it to NuVoc? Perhaps as
>> >> Vocabulary/EmptyArrays?  If you do, I'll point the main NuVoc page to
>> it.
>> >>
>> >> Henry Rich
>> >>
>> >>
>> >> On 6/8/2017 10:35 PM, Devon McCormick wrote:
>> >>
>> >>> J's treatment of empty arrays is thoroughly logical and consistent but
>> >>> it's
>> >>> probably more instructive to look at the shapes of results rather than
>> at
>> >>> the results themselves, since a lot of empty arrays "look" the same
>> though
>> >>> their shapes clearly differ:
>> >>>
>> >>>     0 0 0$99         NB. 3-D empty array
>> >>>     9 0 0$99         NB. 3-D empty array
>> >>>
>> >>> At the risk of obfuscating rather than clarifying, here are some
>> >>> progressions from non-empty to empty arrays - the point here is that
>> not
>> >>> all empty arrays are the same.  Any array with zero as at least one of
>> its
>> >>> dimensions is empty but may have a different shape than another empty
>> >>> array.
>> >>>
>> >>>     $i.2             NB. 2-element vec
>> >>> 2
>> >>>     $1}.i.2          NB. Drop 1 element from 2-element vec
>> >>> 1
>> >>>     $2}.i.2          NB. Drop 2 elements from 2-element vec
>> >>> 0
>> >>>     $3}.i.2          NB. Drop 3 elements from 2-element vec
>> >>> 0                   NB. -> empty vector
>> >>>
>> >>>     $i.2 2           NB. 2x2 mat
>> >>> 2 2
>> >>>     $1}.i.2 2        NB. Drop 1 row from 2x2 mat
>> >>> 1 2
>> >>>     $2}.i.2 2        NB. Drop 2 rows from 2x2 mat
>> >>> 0 2                 NB.  -> mat with no rows
>> >>>     $3}.i.2 2        NB. Drop 3 rows from 2x2 mat
>> >>> 0 2
>> >>>
>> >>>     $1}."1 i.2 2     NB. Drop 1 column from 2x2 mat
>> >>> 2 1
>> >>>     $2}."1 i.2 2     NB. Drop 2 columns from 2x2 mat
>> >>> 2 0                 NB.  -> mat with no columns
>> >>>     $3}."1 i.2 2     NB. Drop 3 columns from 2x2 mat
>> >>> 2 0
>> >>>
>> >>>     <''              NB. Boxed empty
>> >>> ++
>> >>> ||
>> >>> ++
>> >>>     $<''             NB. Boxed empty is a scalar
>> >>>
>> >>>     '' -: $<''       NB. Boxed empty is a scalar
>> >>> 1
>> >>>     (i.0) -: $<''    NB. Boxed empty is a scalar
>> >>> 1
>> >>>     $,<''            NB. 1-element boxed empty
>> >>> 1
>> >>>     a: -: <''        NB. "Ace" is equivalent to boxed empty
>> >>> 1
>> >>>
>> >>>     2$a:             NB. 2-element vector of boxed empties
>> >>> +++
>> >>> |||
>> >>> +++
>> >>>     $2$a:            NB. 2-element vector
>> >>> 2
>> >>>     $1}.2$a:         NB. Drop 1 element from 2-element vector
>> >>> 1
>> >>>     1}.2$a:          NB. Drop 1 element from 2-element vector
>> >>> ++
>> >>> ||
>> >>> ++
>> >>>     $2}.2$a:         NB. Drop 2 elements from 2-element vector
>> >>> 0                   NB.  -> empty vector
>> >>>     '' -: 2}.2$a:    NB. Empty vector
>> >>> 1
>> >>>     '' -: 2}. i.2    NB. Empty vector
>> >>> 1
>> >>>     '' -: 2}. i.2 2  NB. Not empty vector: 0x2 mat
>> >>> 0
>> >>>     (0 2$'hi') -: 2}. i.2 2
>> >>> 1
>> >>>
>> >>> Obligatory empty array joke:
>> >>>    A man sits down in a diner and asks for coffee with no cream.  The
>> >>> waitress replies, "I'm sorry, sir.  We're out of cream.  Would you like
>> >>> your coffee with no milk?"
>> >>>
>> >>>
>> >>>
>> >>> On Wed, Jun 7, 2017 at 1:03 PM, Michael Rice <[email protected]>
>> wrote:
>> >>>
>> >>> @robert therriault
>> >>>>
>> >>>> my_empty =: }. 1
>> >>>>
>> >>>> my_empty
>> >>>>
>> >>>>
>> >>>> f my_empty
>> >>>>
>> >>>> 1
>> >>>>
>> >>>> < my_empty
>> >>>>
>> >>>> ┌┐
>> >>>>
>> >>>> ││
>> >>>>
>> >>>> └┘
>> >>>>
>> >>>>
>> >>>> An empty box?
>> >>>>
>> >>>>
>> >>>> I'm beginning to see the problem I was thinking of doing in J is
>> >>>> ill-suited
>> >>>> to the language. It could be done, as it could in any computer
>> language,
>> >>>> but the solution would be pretty kludgy.
>> >>>>
>> >>>>
>> >>>> I'll soon think of something else on which to apply J. It's already
>> >>>> invading my sleep. Going through exercises is no way to get into a
>> >>>> language. One needs a problem on which to focus it. I've been wanting
>> to
>> >>>> explore cryptography more deeply, and J seems ideal for it.
>> >>>>
>> >>>>
>> >>>> Thanks to all,
>> >>>>
>> >>>>
>> >>>> Michael
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>> On Wed, Jun 7, 2017 at 12:01 PM, robert therriault <
>> >>>> [email protected]>
>> >>>> wrote:
>> >>>>
>> >>>> I'm going to look at these results through the lens of Shape ($)
>> >>>>>
>> >>>>>      f =: (1&,)
>> >>>>>     f 2
>> >>>>> 1 2
>> >>>>>     $ f 2  NB. shape is 2
>> >>>>> 2
>> >>>>>     f ''
>> >>>>> 1
>> >>>>>     $ f '' NB. shape is 1
>> >>>>> 1
>> >>>>>     empty  NB. it is a verb in my environment
>> >>>>> (i.0 0)"_
>> >>>>>     f empty
>> >>>>> f empty   NB. result of two verbs and no arguments is just the two
>> verbs
>> >>>>>     f empty 2  NB. this is where you expect to have a 1 returned
>> >>>>>
>> >>>>>     $ f empty 2  NB. shape is 1 0
>> >>>>> 1 0      NB. one line of no items means no display
>> >>>>>
>> >>>>> I think it is the second dimension of EMPTY as opposed to NULL that
>> is
>> >>>>> tripping you up.
>> >>>>>
>> >>>>>      NULL=.''
>> >>>>>     $ NULL
>> >>>>> 0
>> >>>>>     EMPTY
>> >>>>>     $EMPTY
>> >>>>> 0 0
>> >>>>>     EMPTY-:empty 1
>> >>>>> 1
>> >>>>>
>> >>>>> In answer to your most recent question Michael, I would say just make
>> >>>>>
>> >>>> sure
>> >>>>
>> >>>>> that the empty list that you pass is the right shape.
>> >>>>>
>> >>>>> Cheers, bob
>> >>>>>
>> >>>>> On Jun 7, 2017, at 8:48 AM, Raul Miller <[email protected]>
>> wrote:
>> >>>>>>
>> >>>>>> empty is a verb
>> >>>>>> f is a verb
>> >>>>>>
>> >>>>>> so f empty is a verb (a hook)
>> >>>>>>
>> >>>>>>    f=: 1&,
>> >>>>>>    (f empty) 3
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>>    $(f empty) 3
>> >>>>>> 3 0
>> >>>>>>    $(f empty) 5
>> >>>>>> 5 0
>> >>>>>>
>> >>>>>> The reasons for this are documented at
>> >>>>>> http://www.jsoftware.com/help/dictionary/dictf.htm (hooks) and
>> >>>>>> http://www.jsoftware.com/help/dictionary/d630n.htm (x m&v y).
>> >>>>>>
>> >>>>>> That said, verbs take arguments and empty is a verb - it always
>> >>>>>> produces an empty result, but only when it gets an argument.
>> >>>>>>
>> >>>>>> I hope this helps,
>> >>>>>>
>> >>>>>> --
>> >>>>>> Raul
>> >>>>>>
>> >>>>>>
>> >>>>>> On Wed, Jun 7, 2017 at 11:39 AM, Michael Rice <[email protected]>
>> >>>>>>
>> >>>>> wrote:
>> >>>>>
>> >>>>>> Oops! Guess I creamed empty. Will close and regen Jqt before
>> >>>>>>>
>> >>>>>> proceeding.
>> >>>>
>> >>>>> Done!
>> >>>>>>>
>> >>>>>>>    f =: (1&,)
>> >>>>>>>    f 2
>> >>>>>>> 1 2
>> >>>>>>>    f empty
>> >>>>>>> f empty
>> >>>>>>>
>> >>>>>>> Shouldn't it have returned
>> >>>>>>>
>> >>>>>>> 1
>> >>>>>>>
>> >>>>>>> ?
>> >>>>>>>
>> >>>>>>> On Wed, Jun 7, 2017 at 11:22 AM, robert therriault <
>> >>>>>>>
>> >>>>>> [email protected]>
>> >>>>>
>> >>>>>> wrote:
>> >>>>>>>
>> >>>>>>> One thing to remember is that empty is already defined as a verb
>> >>>>>>>>
>> >>>>>>>>     empty
>> >>>>>>>> (i.0 0)"_
>> >>>>>>>>
>> >>>>>>>> So if you overwrite this you may break some code if you have
>> >>>>>>>>
>> >>>>>>> previously
>> >>>>
>> >>>>> relied on the existing verb definition.
>> >>>>>>>>
>> >>>>>>>> I think along the lines that Pascal mentioned that null could be
>> >>>>>>>>
>> >>>>>>> similarly
>> >>>>>
>> >>>>>> defined as
>> >>>>>>>>
>> >>>>>>>>     null NB. check that it is not already used
>> >>>>>>>> |value error: null
>> >>>>>>>>    null=:(i.0)"_
>> >>>>>>>>    NULL  NB. check that it is not already used - uppercase for
>> global
>> >>>>>>>> nouns is a convention I like and is often seen in J code
>> >>>>>>>> |value error: NULL
>> >>>>>>>>    NULL=:'' NB. I use this as the null string (same as what John
>> >>>>>>>>
>> >>>>>>> suggested)
>> >>>>>
>> >>>>>>    NULL-:null 2 NB. any argument produces NULL from null
>> >>>>>>>> 1
>> >>>>>>>>
>> >>>>>>>> Hope this helps,
>> >>>>>>>>
>> >>>>>>>> Cheers, bob
>> >>>>>>>>
>> >>>>>>>> On Jun 7, 2017, at 8:09 AM, 'Jon Hough' via Programming <
>> >>>>>>>>>
>> >>>>>>>> [email protected]> wrote:
>> >>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>> I may be wrong in doing this, but I usually write
>> >>>>>>>>> empty=: ''
>> >>>>>>>>> to signify an empty list, array, matrix etc.
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>> On Jun 7, 2017, 23:59, at 23:59, Michael Rice <
>> [email protected]>
>> >>>>>>>>>
>> >>>>>>>> wrote:
>> >>>>>>>>
>> >>>>>>>>> Is there a special "noun" for an empty list?
>> >>>>>>>>>>
>> >>>>>>>>>> Creating one seems enigmatic.
>> >>>>>>>>>>
>> >>>>>>>>>> empty =: 1 2
>> >>>>>>>>>> empty
>> >>>>>>>>>> 1 2
>> >>>>>>>>>> empty =: }. empty
>> >>>>>>>>>> empty
>> >>>>>>>>>> 2
>> >>>>>>>>>> empty =: }. empty
>> >>>>>>>>>> empty
>> >>>>>>>>>>
>> >>>>>>>>>> empty1 =:
>> >>>>>>>>>> |syntax error
>> >>>>>>>>>> |   empty1=:
>> >>>>>>>>>> ------------------------------------------------------------
>> >>>>>>>>>>
>> >>>>>>>>> ----------
>> >>>>>
>> >>>>>> 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
>> >>>>
>> >>>>
>> >>>
>> >>>
>> >>
>> >> ---
>> >> This email has been checked for viruses by AVG.
>> >> http://www.avg.com
>> >
>> >>
>> >> ----------------------------------------------------------------------
>> >> 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

Reply via email to