On 6/8/07, Terrence Brannon <[EMAIL PROTECTED]> wrote:
't1' 'f1' 5
't1' 'f2' 5
't1' 'f3' 5
't2' 'f7' 7
't2' 'f8' 7
...
Let's say that you want the compression of this data to be searchable by the
first field, hence you want a list in which each item is 3 boxes like so:
't1' ; (<('f1';'f2';'f3')) ; 5
't2' ; (<('f7';'f8')) ; 7

You have not specified the original format of the data, but let's
say it's a boxed two dimensional array, with as many columns
as sql columns and as many rows as sql rows.
  raw=:('t1 t1 t1 t2 t2',.&;:'f1 f2 f3 f7 f8'),.]&.>5 5 5 7 7

First off, observe that you can group things the way you want using a
/. dyad:
  ({."1 </. ])raw

Now we just need a verb to rearrange things the way you want.
  spread=:4 :'x`:6 y'"0 _1
  ({."1 {.`<`{.&spread@|:/. ])raw
+--+----------+-+
|t1|+--+--+--+|5|
|  ||f1|f2|f3|| |
|  |+--+--+--+| |
+--+----------+-+
|t2|+--+--+   |7|
|  ||f7|f8|   | |
|  |+--+--+   | |
+--+----------+-+

--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to