Kip Murray wrote:
>  This puzzle has two parts (a) what is the error in verb r, and (b) how do 
> you 
>  fix it?  I have an answer for the fix, but there may be better ones.

I'm not sure what your question is, or what the error you refer to is.

However, I do know that these two concepts:

>  r =: (d"_ {~ ] |~ [: # d"_)"0
>  d =: d , 'kty',:'mew'

are incompatible.  Tacit code is functional code.  Given the same inputs,
it produces the same output.  The only thing that can cause a tacit verb
to produce different outputs is different inputs.  The only "mutable"
thing about a tacit verb is its arguments, which it does not mention; so a
tacit verb is immutable [1]. 

But you're trying to make a mutable tacit verb, which is a contradiction. 
You're treating  d  like an argument, without making it an argument (or,
alternatively, you're trying to make a tacit verb mention its argument). 
So you're going to have problems.  When you defined  r  the value of  d 
was "compiled in".

You can't have it both ways.  If you want to refer to mutable global nouns,
you're going to have to use explicit code.  Now, there are tricky ways to
get the behavior you want, such as  replacing  d"_  with  ". bind 'd'  ,
but the "trickee" would be you.  

To use the example above:  ".  is a J interpreter, in  ". bind 'd'  you're
giving it  d  to interpret, which is a noun phrase, which isn't tacit;
hence  r  is not tacit.  Put another way, you would just be fooling
yourself.  There are other tricky ways and they'd all fall victim to the
same sort of analysis [2].

In the end, to refer to mutual global data is to express an explicit verb. 
If you want to express an explicit verb, why not do it the easy way?
           r =:  3 : 'd {~ y |~ #d'

Now, if you're particularly charmed by the tacit expression and don't want
to rephrase it explicitly, you could always take a hybrid approach:

           r =:  3 : 'd' : ([ {~ #...@[ | ])

as long as you're ok with the fact that while  ([ {~ #...@[ | ])  is tacit,  r
 isn't.

-Dan


[1]  Well, I suppose if a tacit verb f depended on another tacit verb g,
you could redefine g and f will have "mutated".  But to that I would say
that you haven't mutated f, you've redefined it.  The new f is a different
verb.  Put another way, in the context of my message above, a tacit verb
is a fully fixed, anonymous verb composed soley of primitives and
anonymous nouns, which makes no use of  n :  .

[2]  The one exception would be memory-mapping  d  , but while this is
"tacit", it is still not functional.  It's basically a cheat, and it's a
lot more work than it's worth.

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

Reply via email to