Hello
Is there an easier way to do the following? My first attempt was:
Given data:
data=: cutopen;._2 ] 0 : 0
0 p1 4
2 p1 6
3 p1 10
13 p1 15
0 p2 3
1 p2 5
7 p2 10
10 p2 11
14 p2 12
1 p3 9
5 p3 10
9 p3 20
7 p4 10
)
I want to build a table with the corresponding data put in in the right
places, such as:
'day id val'=:|:(<a:;0 2)(".&.>@{`[`])} data
coord=:(<"1 day ,. (i.~ ~.) id)
load 'strings'
ysize=:>:>./day
(a:, <"1 ~.id), (<"0 i.ysize),.((<_);<a:) rplc~"1 <"0 val coord}
_$~ysize,#~.id
+--+--+--+--+--+
| |p1|p2|p3|p4|
+--+--+--+--+--+
|0 |4 |3 | | |
+--+--+--+--+--+
|1 | |5 |9 | |
+--+--+--+--+--+
|2 |6 | | | |
+--+--+--+--+--+
|3 |10| | | |
+--+--+--+--+--+
|4 | | | | |
+--+--+--+--+--+
|5 | | |10| |
+--+--+--+--+--+
|6 | | | | |
+--+--+--+--+--+
|7 | |10| |10|
+--+--+--+--+--+
|8 | | | | |
+--+--+--+--+--+
|9 | | |20| |
+--+--+--+--+--+
|10| |11| | |
+--+--+--+--+--+
|11| | | | |
+--+--+--+--+--+
|12| | | | |
+--+--+--+--+--+
|13|15| | | |
+--+--+--+--+--+
|14| |12| | |
+--+--+--+--+--+
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm