I wrote:
> I found 34 foreigns whose nameclass wasn't verb. 

Roger responded:
> All I can say is that you are chasing ghosts.
 
Everyone needs a hobby.  

Anyway, as I said: 
>  I am intrigued.

An hour of investigation was entertaining and instructive, and cleared up a lot 
of the mystery.

First I discovered that most of the extra foreigns were repeats.  It turns out 
foreigns are cyclical.   That is, if there is a
foreign  m!:n  , then there are an infinite number of such foreigns, with the 
relation:

    m!:n  <==>  N!:(n + m -&:(120&*) N)

where N is any scalar integer (except 11 because  11!:  is a callback to the 
frontend, i.e. in Eric's purview).

For example, the following is a different kind of "foreign family" * :

           (,. (5*120) - 120 * ]) i: 5
        _5 1200
        _4 1080
        _3  960
        _2  840
        _1  720
         0  600
         1  480
         2  360
         3  240
         4  120
         5    0

If used as arguments to  !:  these foreigns are all identical to  5!:0  .  Try  
'+'_3!:960  (I should really keep a list of these
things for the inevitable Obfuscated J Competition).

So,  5!:0  accounted for a number of my "illegals" (undocumented foreign[er]s). 
 Scrubbing those from the list, and armed with the
knowledge of the 120-cycle, I concluded that the rest were also aliases, and 
they led me to discover the true culprits,  13!:33
and  13!:34  .

Thanks again to RE Boss' generous donations of old J versions (early xmas!), I 
was able to discover that these two foreigns were
introduced in J 601 beta i ** (well, actually, 13!:34 is much older than that, 
but it was changed in the ibeta ***). 

A directory diff of the two versions and some fiddling led me discover:

        (A)  13!:33  is an adverb that produces the function call depth 
             of its verb argument.  Its definition is something like  
             1 : '1 + L. >^:(1=#) 5!:2 {.;:''u'' '  .  Example:

                   toJ f. 1 : '1 + L. >^:(1=#) 5!:2 {.;:''u'' '
                7
                   toJ f. 13!:33
                7

             I'd guess this is related to the "recursion limit" 
             and/or "stack depth" changes introduced in the ibeta.

        (B)  13!:34  is an adverb that takes a boolean function 
             as an argument and derives a dyad which compares 
             integers.  The boolean functions are (almost) 
             the same as the ones on the  b.  Voc page:

             0 1 *. *: +. +: -. < <: = > >: ~:  NB.  No 0: 1: x y [ ]

             Example:

                   =  13!:34~ 4
                1
                   ~: 13!:34~ 4
                0
                                        
            These results aren't normal booleans in the sense 
            that their internal data type is  256  .  That is,
            256=3!:0=13!:34~4  .I didn't investigate these much 
            further, as  3!:1=13!:34~4 and things like it crash
            J. I peeked around a little with 15!:6  and  15!:1  
            but other than the odd data type, they don't seem
            exceptional.


That's my report.  Like all ghost hunts, it was a success and a failure.  The 
ghosts were but smoke and mirrors.
http://dan.bron.us/case-closed.jpg


-Dan

*    I had a bug in my !:-seeker that prevented many of these from 
     showing up in the original list. 

**   This beta was a big step.  It was announced here:
 
     http://www.jsoftware.com/pipermail/beta/2006-February/000565.html

     This is the beta that removed the inflection from explicit 
     arguments, introduced FSM, changed the recursion limit, 
     decommitted dde, introduced the msg pump,  changed box 
     drawing characters to unicode, and more.

***  Prior to J601 beta i,  13!:34  was a verb .  I didn't investigate 
     too deeply but I discovered:

          a)  It's been around at least since J4.05a, 
              the earliest J version I have running.

          b)  Its ranks were  _ 0 0  .

      c)  The monad always seems to return 0.  
              But I'm sure there's to it than that

          d)  The dyad always seems to return its
          right argument, the domain of which 
          is, AFAICT, unrestricted.  But the 
          left argument appears to be some
          kind of function code.  The only 
          Non-identity "function" I could discover,
          however, was a crash with  _1 (13!:34) a:

I have exhausted my curiosity for the day, however.  Discovering the purposes 
of  13!:34  (both old and new) and divining the
reason foreigns are mod 120 are left as exercises for the (dedicated) reader.  
If you're really zealous you could take the
foreign-seeking code I posted, run it under J4, and start discriminating 
between between valence and domain errors....

There are always more ghosts.

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

Reply via email to