I was poking around in the documentation and found two extremely useful stdlib
verbs:
fwrites: (": data) fwrites 'file'
writes the literal table to file while replacing row seperations (and existing
LFs) by the system-specific LF (that is, LF/CR/CRLF)
freadr: data=: ". freadr 'file'
is the exact inverse
Louis
> On 21 Feb 2016, at 07:31, Linda A Alvord <[email protected]> wrote:
>
> tl=: 13 :'($(":y),"1'' '')$,(":y),"1'' '''
> tl i.2 3 4
> 0 1 2 3
> 4 5 6 7
> 8 9 10 11
>
> 12 13 14 15
> 16 17 18 19
> 20 21 22 23
> $,tl i.2 3 4
> 72
>
> Sorry about the two messages. Linda
> -----Original Message-----
> From: Programming [mailto:[email protected]] On Behalf
> Of Linda A Alvord
> Sent: Sunday, February 21, 2016 1:29 AM
> To: [email protected]
> Subject: Re: [Jprogramming] Formatting tables
>
> Dave, This doesn’t have the two empty ;omes at the emd.
>
>
>
> -----Original Message-----
> From: Programming [mailto:[email protected]] On Behalf
> Of David Lambert
> Sent: Saturday, February 20, 2016 11:26 PM
> To: programming
> Subject: Re: [Jprogramming] Formatting tables
>
> For higher dimensional arrays I use to_literal which builds a vector with
> line feeds to look as though j displayed it. This is suitable for transfer to
> file. For gnuplot two successive blank lines separate the index groups.
>
> rank =: #@:$
> to_literal=: ([:,/,.&LF)"2^:(0>.<:@:rank)@:": NB. as a dyad x is x of ":
> to_literal i. 2 3 4
> 0 1 2 3
> 4 5 6 7
> 8 9 10 11
>
> 12 13 14 15
> 16 17 18 19
> 20 21 22 23
>
>
> $ to_literal i. 2 3 4
> 74
>
>
>> On 02/20/2016 11:05 PM, [email protected] wrote:
>> Date: Sun, 21 Feb 2016 00:39:21 +0100
>> From: Louis de Forcrand<[email protected]> To:[email protected]
>> Subject: [Jprogramming] Formatting tables
>> Message-ID:<[email protected]>
>> Content-Type: text/plain; charset=us-ascii
>>
>> From what I read in the dictionary, all formatting primitives format
>> tables and higher rank arrays into a frame of 1-cells. Is there a way
>> to format a table using LFs between rows, so as to be easy to write to
>> a file?
>> I tried formatting a (huge) rank-2 array of coordinates for gnuplot
>> using
>> farray=: ":!.20 array
>> text=: (, LF&,)/ farray
>> and it's been running for a while now.
>> The funny thing is that the actual initial formatting took under five
>> seconds; I'm pretty sure there's a better way to do this.
>>
>> Louis
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm