The result from erase is telling you that the name is legal to erase.
To get a zero, try erase 'i.'
If you want to see whether the operation succeeded, you'll need to do more work.
One issue you need to consider is the class of the name.
nameClass=: [: nameclass ;: ::]
Only names with a non-negative class can be removed by erase.
Another issue which might interest you is whether the name is defined
locally. This needs work (it gives undefined names a definition), but
is a hint as to how you could test for whether the name is defined
locally:
nameLocal=: [: {.@".@('0[',],'=:',]) ::1:&> ;: ::]
Another issue which might interest you is what locales the name is defined in.
nameLocales=:[: 3 :0 S:0 ;: ::]
path=. ~.(,18!:2)18!:5''
test=.'(p P y)](4!:0<''',y,'__y'')[(''''P y)[p=.(P=.18!:2)y'
<path#~_1<(3 :test)"0 path
)
Example use:
nameClass 'this is a test'
nameLocal 'this is a test'
nameLocales 'this is a test'
nameClass gives you a list of numbers in the range _2 through 3
indicating whether the name is illegal, undefined, noun, adverb,
conjunction or verb.
nameLocal gives you a 1 for names with local definitions (and for
illegal names). Be careful, though, because it will define the name if
it's not already defined.
nameLocale gives you a boxed list of the locales where you can find
the definition of the name.
Anyways... there's lots of ways things could work. But why would you
erase a name in the first place, if you don't know that it exists?
Thanks,
--
Raul
On Wed, Sep 17, 2014 at 10:40 AM, Linda Alvord <[email protected]> wrote:
> For a long time this has puzzled me.
>
>
>
> A=:2 4$i.8
>
> erase 'A'
>
> 1
>
> erase 'A'
>
> 1
>
>
>
> It seems the second time it tells me it erased A it is lying because there
> should be no A any longer.
>
>
>
> Now it is really bothering me.
>
> load 'viewmat'
>
> ]GRB=:1 0 2{"1 (#:i.8){0 255
>
> ]T=:+/~i.16
>
> GRB viewmat T;'T'GRB viewmat i.16
>
>
>
> ]C=:i.12
>
> GRB viewmat C
>
>
>
> ]D=:3 4$i.12
>
> GRB viewmat D
>
>
>
> ]M=:5 3$i.15
>
> GRB viewmat M
>
>
>
> GRB viewmat 7 3$i.21
>
>
>
> ]B=:4 4$i.16
>
> GRB viewmat B
>
>
>
> GRB viewmat |: B
>
>
>
> GRB viewmat |.|:B
>
>
>
> If I run a different script with images in 1.ijs and then run 2.ijs I
> get images all mixed up. Even If I remove all png's from the temp folder,
> ghosts of previous images appear. I turn of JHS.bat and the try 2.ijs
> and old images show up. They seem to be coming from the clipboard possibly.
> Erasing names does not seem to help, but I'd like it better if I only got a
> 1 when it finds something with the given name and then was not willing to
> erase it abain.
>
>
>
> However, it is great to see any images! Also, jqt seems to be unphased
> by thses ghosts.
>
>
>
> Linda
>
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm