There is already a utility 'save_j_' in the distribution that is meant to be 
used in conjunction with 'load' to emulate APL’s )SAVE and )LOAD although tacit 
 adverbs might cause difficulties ( see 
http://www.jsoftware.com/pipermail/general/2003-January/014887.html ).
 
In the same 'Keeping results in J' thread/subject (see 
http://www.jsoftware.com/pipermail/general/2003-January/014471.html ) I 
provided a couple of verbs for the specific task of saving and loading nouns.  
Unfortunately in the forum archive my message appears as HTML code and it is 
difficult to read directly; thus, I am reproducing it here but with an updated 
version of UnPack.
 
-----------------------------------------------------------------------------------------------------------------------------
 
I do not use nouns much nowadays (I use tacit verbs, and save and load the 
results instead). However, these verbs used to do the trick of saving and 
loading nouns (it seems that 4!:1 and a little more code could implement 
all-nouns saving and loading). 
 
Pack=. 3!:1@:(".&.>@:;:@:[) (1!:2 <^:(L. = 0:)) ]
NB. (dyadic verb) (e.g., 'A B C D' Pack 'abcd.bin')
UnPack=. [ 4 : '(x)=: y' 3!:2@:(1!:1@(<^:(L. = 0:)))@:] NB. Updated version
NB. (dyadic verb) (e.g., 'A B C D' UnPack 'abcd.bin')
 
D=. 0 [ C=. < A;B [ B=. 'B' [ A=. 0 1 2
A;B;C;D
 
'A B C D' Pack 'ABCD.bin'
 
erase ;:'A B C D'
A;B;C;D NB. Erased!
  
'A B C D' UnPack 'ABCD.bin'

A;B;C;D
 



----- Original Message ----
From: Leigh J. Halliwell <[EMAIL PROTECTED]>

Dear J Forum:

I would like to save J nouns as permanent datasets in a given directory.
Then, when I start up J, I can read them (hopefully quickly) into J, rather
than creating them afresh each session.  I've looked at J component files,
but I can't see 1) whether they survive after the current session is closed,
and 2) whether they can be assigned to a desired directory.  Thank you for
your help.

Sincerely,

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

Reply via email to