It is 18 November, so below is my solution Table to Linda's challenge.
It is the same as Raul's. However, it does not handle extreme cases
well, and I leave it as a further challenge to repair Table.
The difficulty:
1 Table 2 3
+-+------+
| |2 |
+-+------+
|1| 3 3 4|
+-+------+
1 2 Table 3
+-+----+
| |3 |
+-+----+
|1| 4 5|
|2| |
+-+----+
Flawed solution to Linda's puzzle:
Over
[: ({. ; }.) [: ": ,
By
(' ' ; [: ,. [) ,. ]
Table
[ By ] Over +/
Table f.
[ ((' ' ; [: ,. [) ,. ]) ] ([: ({. ; }.) [: ": ,) +/
a Table b
+-+-------+
| |0 1 2 3|
+-+-------+
|2|2 3 4 5|
|3|3 4 5 6|
|5|5 6 7 8|
+-+-------+
Over and Bye can produce any operation table, but Table can only produce
addition tables.
a By b Over a */ b
+-+---------+
| |0 1 2 3|
+-+---------+
|2|0 2 4 6|
|3|0 3 6 9|
|5|0 5 10 15|
+-+---------+
-------- Original Message --------
Subject: [Jprogramming] table challenge in simple J
Date: Sun, 13 Nov 2011 20:51:50 -0500
From: Linda Alvord <[email protected]>
Reply-To: Programming forum <[email protected]>
To: 'Programming forum' <[email protected]>
In the dictionary in the section on "Verbs and Adverbs" there are two
definitions designed to produce a table:
over=:({.;}.)@":@,
by=:' '&;@,.@[,.]
a=: 2 3 5
b=: 0 1 2 3
a by b over a +/ b
--T-------┐
│ │0 1 2 3│
+-+-------+
│2│2 3 4 5│
│3│3 4 5 6│
│5│5 6 7 8│
L-+--------
Here is the challenge. Use the arguments a and b and define a single tacit
function in "simple J" that does not use @ and provides the same result.
a table b
--T-------┐
│ │0 1 2 3│
+-+-------+
│2│2 3 4 5│
│3│3 4 5 6│
│4│4 5 6 7│
L-+--------
To give a little time for thought, do not post a solution until November
18th. I'll post mine then too.
Linda
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm