June Kim wrote:
> v1=:+
> v2=:*
> v3=:-
> g1=:v1`v2`v3
>
> insert=:verb define
> v=.y`:6
> v2=.v/
> {.(v2 f.)`''
> )
...
> Accidentally, there was the same name used in the code. v2 was used
> as public and private. As far as I know, they don't collide each
> other and you don't need to worry about private names polluting
> the public namepsace and that's why private assignment exists.
When debugging, it's often useful to inspect intermediate results.
Two useful approaches are breakpoints and injecting code to display
those results.
Here's an example of your insert verb modified to display intermediate
results:
insert=:verb define
v=.y`:6
smoutput 5!:1<'v'
v2=.v/
smoutput 5!:1<'v2'
{.(v2 f.)`''
)
I think this makes clear what's going on:
When v is 'v1', v2 is v1/ and can be fixed using the global
value for v1
When v is 'v2', v2 is v2/ and v2 f. can't do anything useful
with that, so leaves it alone.
To achieve what I think you were trying to do, I might use
insert=:verb define
v=.y`:6 f.
v2=.v/
{.(v2 f.)`''
)
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm