Hello
I recently read Reading to Write by Raymond P. Polivka from APL QUOTE
QUAD. It is written with APL examples. I am interested in the Block
Printing example.
I think I understand all the expressions except the last line in the
function, BV\[2]Z. How would it translate into J?
And, a better solution in J, if any, using J's advantages?
Following is an exceprt from the article(sorry for my ignorance of
APL's verb/operator names):
Problem:
Unfortunately not all programs work the way they are intended to work.
If you examine the test cases which accompany the display of the
function you will finnd the function called BLOCK has a bug in it.
Now, the function called BLOCKC behaves properly,
a. You are to fix BLOCK so that it behaves correctly, that is, it acts
like BLOCKC.
b. Modify the function so that it will allow both the number of blocks
per line and the number of characters per group to be arbitrary.
Z {left arrow} N BLOCK V;MUL;ROW;COL;BV
{A} V: A SIMPLE CHAR. VECTOR
{A} N: PAGE WIDTH- A POSITIVE INTEGER
{A} Z: A SIMPLE CHAR. MATRIX OF V DIVIDED INTO N GROUPS OF 3 ACROSS THE PAGE.
MUL {left arrow} ( {rho}V)+3-3|{rho}V <comment>I guess rho is
equivalent to shape $</comment>
V {left arrow} MUL {up arrow} V <comment>I guess up arrow is
"take" {. </comment>
COL {left arrow} N * 3
ROW {left arrow} L ({rho} V) % COL
Z {left arrow} (ROW,COL) {rho} V
BV {left arrow} (N*4) {rho} 1 1 1 0
Z {left arrow} BV\[2] Z
{A} NB THIS FCN HAS A BUG
V
ABBBCCCCCCDDEEFFF
{rho}V
17
2 BLOCK V
ABB BCC
CCC CDD
EEF FF
3 BLOCK V
ABB BCC CCC
CDD EFF FF
4 BLOCK V
ABB BCC CCC CDD
5 BLOCK V
ABB BCC CCC CDD EEF
3 BLOCKC V
ABB BCC CCC
CDD EEF FF
4 BLOCKC V
ABB BCC CCC CDD
EEF FF
5 BLOCKC V
ABB BCC CCC CDD EEF
FF
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm