output formatting

2023-09-09 Thread Stephen Lewis via Bugs and suggestions for GNU APL
I am a novice and I am using APL to calculate the
points for a surface. The output will go to another
program. The goal is to write a matrix, with the correct number of rows
and columns, to a file. Elements should be separated by 
and rows should be separated by . I have found that
the output is formatted in an unexpected way.

Test case to write a matrix with 2 rows of 50 columns.
Is there any way to write a matrix with correct shape
to a file when rows exceed 80 characters? I have tried
the following:

Method 1
script_1.apl:
-
2 50⍴⍳100
-
apl < script_1.apl
apl < script_1.apl > out_1.txt
Writes welcome banner, elements in 4 row matrix with spurious
extra  characters and four messages about end-of-input
and a goodbye message and also writes to stderr.
Method 2
apl -f script_1.apl
apl -f script_1.apl > out_2.txt
Writes welcome banner, elements in 4 row matrix with spurious
extra  characters  and a goodbye message and remains in
'apl' unless stdout is redirected to a file or )OFF added to script.
Method 3
script_2.apl:
-
#! /usr/bin/apl --script --OFF
2 50⍴⍳100
-
./script_2.apl
./script_2.apl > out_3.txt
Must add )OFF to script or use --OFF.
Writes elements in 4 row matrix with spurious
extra  characters and a blank line.
I would like two rows of 50 elements but
output file looks like this:
-
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 
  27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49  50
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 
  77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

-
-- 
Stephen Lewis 

Re: output formatting

2023-09-09 Thread Chris Moller
Try adding the option "--PW 1000" (or any large number less than 
1).  That will set the print width to huge.


The tr utility with the -s option can compress repeated spaces into a 
single space.


sed '$d' will kill the last line.

So something like

   apl --PW 500 --eval "2 70⍴⍳140" | tr -s ' ' | sed '$d'


should work.

On 9/9/23 19:07, Stephen Lewis via Bugs and suggestions for GNU APL wrote:

I am a novice and I am using APL to calculate the
points for a surface. The output will go to another
program. The goal is to write a matrix, with the correct number of rows
and columns, to a file. Elements should be separated by 
and rows should be separated by . I have found that
the output is formatted in an unexpected way.

Test case to write a matrix with 2 rows of 50 columns.
Is there any way to write a matrix with correct shape
to a file when rows exceed 80 characters? I have tried
the following:

Method 1
script_1.apl:
-
2 50⍴⍳100
-
apl < script_1.apl
apl < script_1.apl > out_1.txt
Writes welcome banner, elements in 4 row matrix with spurious
extra  characters and four messages about end-of-input
and a goodbye message and also writes to stderr.
Method 2
apl -f script_1.apl
apl -f script_1.apl > out_2.txt
Writes welcome banner, elements in 4 row matrix with spurious
extra  characters  and a goodbye message and remains in
'apl' unless stdout is redirected to a file or )OFF added to script.
Method 3
script_2.apl:
-
#! /usr/bin/apl --script --OFF
2 50⍴⍳100
-
./script_2.apl
./script_2.apl > out_3.txt
Must add )OFF to script or use --OFF.
Writes elements in 4 row matrix with spurious
extra  characters and a blank line.
I would like two rows of 50 elements but
output file looks like this:
-
  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
   27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49  50
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
   77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

-




OpenPGP_0xDA6C0193083E.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Re: output formatting

2023-09-09 Thread Bill Daly
If you change your printing width APL may not print the overflow of each 
line as a separate line.


  tmp←2 50 ⍴ ⍳ 100

  ⎕pw←225
  tmp
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 
49  50
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
99 100


It might be better to use apl to write your out put file:

  )copy 5 DALY/export
DUMPED 2023-07-17  17:07:29 (GMT-4)
NEW )COPY_ONCE workspace: 5 DALY/utf8
DUMPED 2023-07-17  16:44:54 (GMT-4)
NEW )COPY_ONCE workspace: 5 DALY/utl
DUMPED 2023-08-07  15:46:53 (GMT-4)
  tmp←2 50 ⍴ ⍳ 100
  tmp export∆array '/home/dalyw/staging/tmp.txt'
0

file tmp.txt has a tab character between each datum rather than a 
space.  It it must be a space you can modify export∆array.


w

On 9/9/23 19:07, Stephen Lewis via Bugs and suggestions for GNU APL wrote:

I am a novice and I am using APL to calculate the
points for a surface. The output will go to another
program. The goal is to write a matrix, with the correct number of rows
and columns, to a file. Elements should be separated by 
and rows should be separated by . I have found that
the output is formatted in an unexpected way.

Test case to write a matrix with 2 rows of 50 columns.
Is there any way to write a matrix with correct shape
to a file when rows exceed 80 characters? I have tried
the following:

Method 1
script_1.apl:
-
2 50⍴⍳100
-
apl < script_1.apl
apl < script_1.apl > out_1.txt
Writes welcome banner, elements in 4 row matrix with spurious
extra  characters and four messages about end-of-input
and a goodbye message and also writes to stderr.
Method 2
apl -f script_1.apl
apl -f script_1.apl > out_2.txt
Writes welcome banner, elements in 4 row matrix with spurious
extra  characters  and a goodbye message and remains in
'apl' unless stdout is redirected to a file or )OFF added to script.
Method 3
script_2.apl:
-
#! /usr/bin/apl --script --OFF
2 50⍴⍳100
-
./script_2.apl
./script_2.apl > out_3.txt
Must add )OFF to script or use --OFF.
Writes elements in 4 row matrix with spurious
extra  characters and a blank line.
I would like two rows of 50 elements but
output file looks like this:
-
  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
   27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49  50
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
   77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

-