Ian - to save variables to file, I use my own "WS" namespace - see http://www.jsoftware.com/jwiki/Scripts/File%20J%20Variables - or a more general workspace saver: http://www.jsoftware.com/jwiki/Scripts/WS%20Files .
On Tue, Apr 6, 2010 at 5:29 AM, Ian Clark <[email protected]>wrote: > I was afraid that would be the answer. > > The inconvenience to my code is negligible. It just needs one more > line, with an (if.) in it. What distresses me is my failure to > understand why it happens. It makes me suspicious of my whole > data-storage approach. > > I need to store a 2-D integer array, call it z, in an ascii text file > and recover it on reloading the file. > Suppose 'a b'=:$z > Proviso: z is one of several arrays of mixed data. I want to retain a > visual check on the file contents that they all match-up by rows > (numbered: i.a). Without this proviso, a sensible thing to do is to > store the contents of z as a vector and reconstruct it from a > knowledge of the number of rows, (a). > Taking a simple minded approach, however, I can use (":) to stuff z in > a file, and (".) to recover it again from the (2-D) file image. This > seems adequate and reliable provided a>1 and b>1. I just wouldn't have > anticipated it breaking down for b=1, which is not an uncommon case to > arise. > > Clearly this is not the approach an experienced J-er would take, and > I'd like to know what that is. > > I don't want to drag this thread off-topic. It just seemed related in > my mind to the problem of predicting the number of display-lines in z > -- or do I mean (":z)? Or (". ":z)? > > Ian > > > On Tue, Apr 6, 2010 at 12:29 AM, Roger Hui <[email protected]> wrote: > > It's a feature, an inevitable consequence of numeric > > conversion and rank. If it breaks your code you have > > to rewrite your code. > > > > > > > > ----- Original Message ----- > > From: Ian Clark <[email protected]> > > Date: Monday, April 5, 2010 16:12 > > Subject: Re: [Jprogramming] lines in display > > To: Programming forum <[email protected]> > > > >> On not quite the same problem but a related one: > >> > >> If z is an integer table, under what conditions would you expect > >> ": z > >> to have the same number of rows as z? Under more restricted > >> conditions, when is (z -: ". ": z) ? > >> > >> Clearly you can't expect rank to be preserved if z=: i.1 3 --since > >> under ": the information gets lost to enable you to distinguish it > >> from i.3. But what about z=: i.3 1 ? > >> > >> Consider the following: > >> > >> (". ": i.z) ; i.z=: 3 2 > >> +---+---+ > >> |0 1|0 1| > >> |2 3|2 3| > >> |4 5|4 5| > >> +---+---+ > >> (". ": i.z) ; i.z=: 3 1 > >> +-----+-+ > >> |0 1 2|0| > >> | |1| > >> | |2| > >> +-----+-+ > >> > >> Is this a bug or a feature? (It's breaking my code, for which I have > >> so far only found an inelegant fix). > >> > >> Ian > >> > >> > >> On Fri, Apr 2, 2010 at 10:20 PM, Roger Hui <[email protected]> wrote: > >> > If x is a rank 2 or higher numeric array, how many > >> > lines are in the display of x? For example, > >> > there are 14 lines in the display of i. 3 4 5 . > >> > > >> > I've worked on a related problem on-and-off for years, > >> > starting in 1991, and only came to a good answer > >> > for this problem just a few days ago. > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Devon McCormick, CFA ^me^ at acm. org is my preferred e-mail ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
