The premise is false.  Copies of the inputs are rarely made, usually only when conversion is required.  When possible, the argument is operated on inplace with the result occupying the same memory as the argument.

Art does have a point about the Nub documentation, but it is important that the opening lines of the NuVoc entry focus on answering the question "What does ~. y do?" without repeating boilerplate to the effect that the result is distinct from the argument.  Nobody expects -5 to change the value of 5, or ~.a to change the value of a.  IMO that entry is OK as it stands.

Henry Rich



On 6/9/2022 6:09 AM, Arthur Anger wrote:
All--
Each non-assigment step in a computation produces copies(!) of its inputs, 
selected and arranged in various specified ways, awaiting disposition--in 
another step, in assignment to storage, in output, or in discard.

At the very least, any recipe for processing an array should begin with some version of 
"Take a copy of y, then...", and consistently refer to that copy, rather than 
to y.

As an example, the page for Nub currently contains the following statements:
   Removes duplicates from a list 
<https://code.jsoftware.com/wiki/Vocabulary/AET#List>.

   More generally, removes any item 
<https://code.jsoftware.com/wiki/Vocabulary/AET#Item> of an array 
<https://code.jsoftware.com/wiki/Vocabulary/AET#Array> that matches a preceding item.

   1. Remove duplicate values 
<https://code.jsoftware.com/wiki/Vocabulary/Glossary#Value> from a lis 
<https://code.jsoftware.com/wiki/Vocabulary/AET#List>t

   2. Remove duplicate rows from a table 
<https://code.jsoftware.com/wiki/Vocabulary/AET#Table>
I recommend replacing them with:
   Copies items from a list, omitting duplicates.
   More generally, omits any item 
<https://code.jsoftware.com/wiki/Vocabulary/AET#Item> of an array 
<https://code.jsoftware.com/wiki/Vocabulary/AET#Array> that matches a preceding item.
   1. Omit duplicate values 
<https://code.jsoftware.com/wiki/Vocabulary/Glossary#Value> from a lis 
<https://code.jsoftware.com/wiki/Vocabulary/AET#List>t
   2. Omit duplicate rows from a table 
<https://code.jsoftware.com/wiki/Vocabulary/AET#Table>

The language used to describe a verb often suggests that its result will 
somehow replace the values being operated on, which will be (nearly) accurate 
only if followed immediately by re-assignment to the same, named, argument.

I urge that any new documentation observe this distinction, and that any 
definition being updated follow this pattern.  If there is a consensus that 
this is a worthy cause, I shall be willing to propose such changes where I may 
encounter them in coming months.
--Art



----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


--
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

Reply via email to