J avoids a pitfall in scalar language amend by replacement. It verifies
that the replacement won't crash half-way through leaving the data
corrupted. It is transparent to the program whether the amend amends in
place or not, other than performance. And sometimes amend makes more sense
than other ways to replace parts of an array. What ever is most
understandable to the programmer.


On Tue, Jul 8, 2014 at 5:05 PM, Erling Hellenäs <[email protected]>
wrote:

> In most languages indexed replacement is indexed replacement? In J and in
> most functional languages it is not? You get a brand new variable? So, why
> give the user the flawed impression he can still do indexed replacement and
> do amendments to variables/nouns? And at the same time in tacit code we
> pretend to only have functions? No variables/nouns to be amended? Just
> functional transformations?
> /Erling
>
> On 2014-07-09 00:21, Jose Mario Quintana wrote:
>
>> Erling wrote: "It's obviously not possible to do any amendments in tacit
>> code?"  Adding after wards: "A principle of functional programming is you
>> never modify a variable?"
>>
>>
>>
>>  From my perspective those (rhetorical?) questions are separate.
>>  Regarding
>> the first question, consider the verb (v) that produces the squares of an
>> amendment produced by the verb amend.  For example,
>>
>>
>>
>>     ( v=. *: @: amend f. )
>>
>> *:@:(_: 0&({::)@]`(1&({::)@])`(2&({::)@])} ])
>>
>>
>>
>>     v (0 1 2 ; 2 3 5 ; 7#9)
>>
>> 81 81 0 1 81 4 81
>>
>>
>>
>> The verb (v) is tacitly defined (is it not?) and amendment is performed
>> via
>> } (is it not?); thus the answer to the first question is that it is
>> possible.  Furthermore, the conclusion is reached regardless of what the
>> meanings of “functional programming” and “variable” might, or might not,
>> be.  (Am I missing something?).
>>
>>
>> On Mon, Jul 7, 2014 at 6:45 PM, Erling Hellenäs <[email protected]
>> >
>> wrote:
>>
>>  Yes, what I said is it seems like a misnomer. Functional J has variables,
>>> but they are handled by the interpreter? Still they are never changed?
>>> This
>>> could create a performance problem if you do a lot of small changes to
>>> big
>>> data structures? It is essential to handle this efficiently? Still J does
>>> not have lazy execution? The functional transformations Amend does are
>>> immediately executed? Maybe J sometimes only creates new pointers to old
>>> static data structures? /Erling
>>>
>>>
>>> On 2014-07-08 00:21, Jose Mario Quintana wrote:
>>>
>>>  What variable? Tacit programming does not refer to any arguments
>>>> explicitly; or, are you saying that “amend” is a misnomer (if so, that
>>>> is
>>>> not my domain)?
>>>>
>>>>
>>>> On Mon, Jul 7, 2014 at 6:07 PM, Erling Hellenäs <
>>>> [email protected]
>>>> wrote:
>>>>
>>>>   A principle of functional programming is you never modify a variable?
>>>>
>>>>> What
>>>>> Amend does is create a new variable from other existing variables?
>>>>> Nothing
>>>>> is amended? /Erling
>>>>>
>>>>>
>>>>> On 2014-07-07 23:50, Jose Mario Quintana wrote:
>>>>>
>>>>>   Erling wrote:
>>>>>
>>>>>> "
>>>>>> It's obviously not possible to do any amendments in tacit code? It is
>>>>>> also
>>>>>> less elegant to pass these three parameters in the two arguments in
>>>>>> tacit
>>>>>> code?
>>>>>> "
>>>>>>
>>>>>> Well, Raul and I showed general verbs to perform amendments tacitly.
>>>>>>   Once
>>>>>> I was as puzzled as you are (were?) but I found enlightenment; maybe
>>>>>> you
>>>>>> can find it as well:
>>>>>> http://www.jsoftware.com/pipermail/general/2000-September/004192.html
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, Jul 7, 2014 at 1:53 PM, Erling Hellenäs <
>>>>>> [email protected]
>>>>>> wrote:
>>>>>>
>>>>>>    It's obviously not possible to do any amendments in tacit code? It
>>>>>> is
>>>>>>
>>>>>>  also
>>>>>>> less elegant to pass these three parameters in the two arguments in
>>>>>>> tacit
>>>>>>> code? Any opinions about the use of From to do the same thing?
>>>>>>>
>>>>>>>
>>>>>>> NB. x and y are arrays of the same rank
>>>>>>> NB. q is a boolean, also of this rank
>>>>>>> NB. The expression merges x and y.
>>>>>>> NB. Where q is TRUE it picks from y, otherwise x
>>>>>>> NB. q {"0 1 x,"0 y
>>>>>>>
>>>>>>> If q is a vector and if we actually have a variable z of rank
>>>>>>> (+/q),}.$y
>>>>>>> we can easily create x from q#^:_1 [ z ? No use for any indexes?
>>>>>>>
>>>>>>> /Erling
>>>>>>>
>>>>>>>
>>>>>>>    ------------------------------------------------------------
>>>>>>> ----------
>>>>>>>
>>>>>>>  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

Reply via email to