maybe worth noting,

'' -: i.0
1




________________________________
From: robert therriault <[email protected]>
To: [email protected] 
Sent: Wednesday, June 7, 2017 11:22 AM
Subject: Re: [Jprogramming] Empty lists?



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

Reply via email to