[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
output formatting
From: |
Stephen Lewis |
Subject: |
output formatting |
Date: |
Sat, 9 Sep 2023 16:07:47 -0700 |
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 <space>
and rows should be separated by <newline>. 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 <space> 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 <space> 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 <space> 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 <lewis+apl@sdf.org
- output formatting,
Stephen Lewis <=