>On my machine (windows xp,32bit) something is not quite right with how {.
>works with variables that are mapped to files.

I cannot speak to Linux or 64 bit OSes, but I confirm this bug on my Windows XP 
(32) system.  

I do not believe the bug is limited to the dyad  {.   .  I believe it related 
to mapped boxed arrays in general.   I recommend against mapping boxed arrays. 

If you're just using boxes of characters to represent strings, I recommend 
mapping an integer array like this:

           require'jmf'
           createjmf_jmf_'test100';10000
           map_jmf_ 'mapped';'test100'
        
           s2i    =:  6 s: s:
        
           data   =:  ;:'BPL C D E F G H I'
           
           mapped =: s2i data
           mapped
        1 2 3 4 5 6 7 8
           
           s2i^:_1 mapped
        +---+-+-+-+-+-+-+-+
        |BPL|C|D|E|F|G|H|I|
        +---+-+-+-+-+-+-+-+

If you need to use the mapped file in another J session, either in parellel as 
shared array, or later, in a new J session, you must persist the symbol table:

            require 'files'

            NB.  Write symbol table to disk      
            (3!:1 ] 0 s: 10) fwrite jpath '~temp\symbols.jsym'
        116336
           

            NB.  Update symbol table
            s2i ;:'new symbols here'
        9 10 11

           s2i^:_1: 9 10 11
        +---+-------+----+
        |new|symbols|here|
        +---+-------+----+

           NB.  Restore old symbol table
           10 s: 3!:2 fread jpath '~temp\symbols.jsym'
        1

           NB.  Updates lost
           s2i^:_1: 9 10 11
        |index error
        |       s2i^:_1:9 10 11

If you don't need to "look inside" the boxes (i.e. manipulating the 
characters), then symbols are functionally equivalent to boxed strings.  But 
symbols are significantly more efficient (so long as you don't have too many 
unique strings.  I don't know what "too many" is, though).

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

Reply via email to