Thank you Bill.
I'd only just met the behaviour yesterday, with (;) in place of '([)
-- which works too, and is slightly more revealing...
I was just playing with Ambrus's example, trying to make it
conceptually even simpler. I find I can get the effect to work with
(".) as well as (3 :), which is good. Because coding grunts won't
relate to themselves defining a verb in-line, but executing a string
is much more likely.
I'd got to here, and was puzzling about sample 3 vs sample 2, when
your reminder arrived of how J parses "trains" (have I got the right
term?) -- in order to implement hooks and forks I guess.
____________________
a=: 5
a ;; 3 :'a=: 10'0 NB. ;; needed for same reason as [[
+--+--+
|10|10|
+--+--+
a=: 5
a ; a ; (3 :'a=: 10')0 NB. J needs to read last 4 tokens at once
+--+-+--+
|10|5|10|
+--+-+--+
a=: 5
a ; a ; (a=:10) NB. but here it doesn't
+--+--+--+
|10|10|10|
+--+--+--+
a=: 5
a ; a ; ".'a=:10' NB. but here again it does
+--+-+--+
|10|5|10|
+--+-+--+
a=: 5
a ;; ".'a=:10' NB. so this is safer
+--+--+
|10|10|
+--+--+
____________________
On Tue, Oct 26, 2010 at 3:42 PM, bill lam <[email protected]> wrote:
> Thank you, indeed very simple example.
>
> Ian, J interpreter have to read the last 4 elements [1] just before
> evaluation of [
>
> a [ v 0 ( noun verb verb noun )
>
> so that before the monad v is evaluated, the value of a has already been
> read into stack. The side effect of v does not change the value of a which
> is already inside the stack.
>
> [1] ~help/dictionary/dicte.htm
>
> Втр, 26 Окт 2010, Zsbán Ambrus писал(а):
>> 2010/10/26 Ian Clark <[email protected]>:
>> > Can you give a very simple example please, Bill, where [[ would make a
>> > difference?
>>
>> a=: 5
>> 2*a[3 :'a=: 10'0
>> 10
>> a=: 5
>> 2*a[[3 :'a=: 10'0
>> 20
>>
>> Ambrus
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>
> --
> regards,
> ====================================================
> GPG key 1024D/4434BAB3 2008-08-24
> gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm