for your is verb, you want y to be the assigned variable to support monadic
verbs.
is =: 1 : (':';'(y) =: x u y~'
to support x u is 'a b',
'a b'~ would have to be defined as 'a'~ ; 'b'~
and then, '`a b c'~ could be defined as (a ar), (b ar), (c ar)
where
ar =: 1 : '5!:1 <''u'''
________________________________
From: Raul Miller <[email protected]>
To: Programming forum <[email protected]>
Sent: Tuesday, July 4, 2017 2:12 PM
Subject: Re: [Jprogramming] Request for comments: multiple assignment
It might be interesting to try redefining the dictionary II.E parsing
rules at http://www.jsoftware.com/help/dictionary/dicte.htm to support
stuff like a+=:i.20
That said, you can already do this:
a=:10
is=:1 :(':';'(y)=:(".x) u y')
'a'+is i.20
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
And, maybe that's good enough, since it's not really clear what should
be done for most of the potential left arguments for =:
b=:9
'a b',is 1
|syntax error
| a b
Or, for example:
a=:+/`%
'`a',is #`''
+-+
|#|
+-+
We could patch those things up, and we could replace the definition
with a tacit version based on ". (perhaps with explicit helpers), to
allow an =. workalike, but the real problem with this line of thinking
is that a C expression like *p+=3 is not what you want to be doing in
J. What you should be trying to do is >>understand what the C
implementation is doing<< and implementing that understanding in J.
And, if you do not understand the C code, you should probably spend
some time instrumenting and debugging the C code to build up that
understanding. Or, work forward from the original specifications (to
the degree that they exist at all - if you get enough people working
on a system you'll wind up with all sorts of contradictory details -
most of which should be ignored, but some of which people will have
come to want and occasionally even need).
Anyways this could be a fun exercise - but probably one which should
be discarded after completing.
Thanks,
--
Raul
On Tue, Jul 4, 2017 at 1:55 PM, 'Mike Day' via Programming
<[email protected]> wrote:
> Not multiple assignment, but copula-related.
>
> I've often wondered why J doesn't have the C family feature of assignments
> such as
> t =: 1 2 3
> [t+=: 3
> 4 5 6
>
> I don't know what it's called, and I realise it's only an arguably
> attractive
> feature, not an essential one, but would be useful, especially when
> translating
> (or plagiarising) to J from C-like code.
>
> John Scholes et al managed to include it in Dyalog APL many years ago; it's
> in his "dfns" (dynamic functions, I think) as well as their more
> conventional
> APL functions and session operations. If I recall correctly, John spells
> out rules
> for passing values to variables of local scope within dfns using such
> operators.
>
> Dyalog doesn't have constructs like t++, though.
>
> Thanks,
> Mike
>
>
> On 04/07/2017 06:40, HenryRich wrote:
>>
>> Here is a feature that I have wanted for a long time:
>>
>>
>> http://code.jsoftware.com/wiki/System/Interpreter/Requests#Expanded_Multiple_Assignment
>>
>> It attempts to solve the problem of moving verb arguments into
>> variable-names. Allows defaults and multilevel arguments. I will implement
>> this within a month or so, so get your comments in ASAP.
>>
>> Henry Rich
>>
>> ---
>> 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
>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
>
> ----------------------------------------------------------------------
> 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