A bit similar to Raul's but without using {. (more generalizable if you had 
more columns)

 <"_1 > (;"0 leaf)"1 /    (< _1]\ 0 1 2), (< _1]\ 'a','b','c')


for input of: 
   0 1 2 ;'abc'; 3 4 5
┌─────┬───┬─────┐
│0 1 2│abc│3 4 5│
└─────┴───┴─────┘

This pattern will get you each row:

   0{ L:1 &.(<"0 each)  ] 0 1 2 ;'abc'; 3 4 5
┌─┬─┬─┐
│0│a│3│
└─┴─┴─┘

this is interesting:
   0 1 2{ L:1 &.(<"0 each)  ] 0 1 2 ;'abc'; 3 4 5
┌─┬─┬─┐
│0│b│5│
└─┴─┴─┘

for a full general transform of any size and oddly shaped/typed columns:

   ,. leaf 0 1 2 ;'abc'; 3 4 5
┌─┬─┬─┐
│0│a│3│
│1│b│4│
│2│c│5│
└─┴─┴─┘

   <"1 |: ,. > (<"0 each) ,. leaf 0 1 2 ;'abc'; 3 4 5
┌───────┬───────┬───────┐
│┌─┬─┬─┐│┌─┬─┬─┐│┌─┬─┬─┐│
││0│a│3│││1│b│4│││2│c│5││
│└─┴─┴─┘│└─┴─┴─┘│└─┴─┴─┘│
└───────┴───────┴───────┘

  <"1 |: ,. > (<"0 each) (< _1]\ 0 1 2), (< _1]\ 'a','b','c')
┌─────┬─────┬─────┐
│┌─┬─┐│┌─┬─┐│┌─┬─┐│
││0│a│││1│b│││2│c││
│└─┴─┘│└─┴─┘│└─┴─┘│
└─────┴─────┴─────┘

also works if original data is kept unshaped (its still column data, but not 
displayed with ,.)

   <"1 |: ,. > (<"0 each)  0 1 2 ;'abc'; 3 4 5
┌───────┬───────┬───────┐
│┌─┬─┬─┐│┌─┬─┬─┐│┌─┬─┬─┐│
││0│a│3│││1│b│4│││2│c│5││
│└─┴─┴─┘│└─┴─┴─┘│└─┴─┴─┘│
└───────┴───────┴───────┘


----- Original Message -----
From: Joe Bogner <[email protected]>
To: [email protected]
Cc: 
Sent: Saturday, October 5, 2013 12:07:50 PM
Subject: [Jprogramming] row from boxes

Given this structure:
]a =. (< _1]\ 0 1 2), (< _1]\ 'a','b','c')

+-+-+

|0|a|

|1|b|

|2|c|

+-+-+


How can I transform it into this?


(0;'a');(1;'b');<(2;'c')


+-----+-----+-----+

|+-+-+|+-+-+|+-+-+|

||0|a|||1|b|||2|c||

|+-+-+|+-+-+|+-+-+|

+-----+-----+-----+


I've tried every variant in indexing and selecting to no avail. Thank you


http://www.jsoftware.com/help/jforc/more_verbs_for_boxes.htm

http://www.jsoftware.com/docs/help701/learning/06.htm

http://www.jsoftware.com/help/primer/from_boxed_indexes.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to