Or you can reshape as you cut

   (>:>./([:+/' '&=);._2 A)&[EMAIL PROTECTED];._2 A
+----+--+-----+---+-----+---+--+----+
|aaa |bb|cccc |dd |e    |aaa|bb|cccc|
+----+--+-----+---+-----+---+--+----+
|1111|22|33333|444|55555|6  |7 |8   |
+----+--+-----+---+-----+---+--+----+

Note: the left part is executed once:

   (>:>./([:+/' '&=);._2 A)&[EMAIL PROTECTED];._2 
8&[EMAIL PROTECTED];._2

This is an instance of necessarily explicit expression
due to impossiblity to pass an arguments beyond
a conjunction.


--- Oleg Kobchenko <[EMAIL PROTECTED]> wrote:

> A=: 0 : 0
> aaa bb cccc dd e
> 1111 22 33333 444 55555 6 7 8
> )
> 
>    ($ $ -.&a:)"1 cut;._2 A
> +----+--+-----+---+-----+---+--+----+
> |aaa |bb|cccc |dd |e    |aaa|bb|cccc|
> +----+--+-----+---+-----+---+--+----+
> |1111|22|33333|444|55555|6  |7 |8   |
> +----+--+-----+---+-----+---+--+----+
>    
> 
> --- Yuvaraj Athur Raghuvir <[EMAIL PROTECTED]> wrote:
> 
> > This is regarding reading and working with data from files.
> > (if text garbled, view it in Courier New font)
> > 
> > 1) Input file:
> > aaa bb cccc dd e
> > 1111 22 33333 444 55555 6 7 8
> > 
> > 2) Read input as an array of values.
> > 
> > data =: cut"1 'm' freads y  NB. y is the fully qualified file name
> > 
> > data
> > +----+--+-----+---+-----+-+-+-+
> > |aaa |bb|cccc |dd |e    | | | |
> > +----+--+-----+---+-----+-+-+-+
> > |1111|22|33333|444|55555|6|7|8|
> > +----+--+-----+---+-----+-+-+-+
> > 
> > 3) Now, pad the matrix in a way similar to $ operator for each dimention.
> > So, end result should look like:
> > +----+--+-----+---+-----+----+----+-----+
> > |aaa |bb|cccc |dd |e    | aaa| bb |cccc |
> > +----+--+-----+---+-----+----+----+-----+
> > |1111|22|33333|444|55555|6   |7   |8    |
> > +----+--+-----+---+-----+----+----+-----+
> > Here is where I am not clear what is happening....
> > Attempt 1:
> > 
> > row =: 0 { $ data
> > 
> > col =: 1 { $ data
> > 
> > 
> > NB. removes empty words
> > 
> > NB. --->>> something goes wrong here...
> > 
> > trim =: cut @: dltb @: , @: >
> > 
> > NB. expands the list to the right size
> > 
> > pad =: 4 : '(1,x)$trim y'
> > 
> > datax =:,. col pad"0 1 data NB. Creates the catalog
> > 
> > datax
> > +----+--+--------+------+---+--+------+--+
> > |aaa |bb|ccccdd  |e     |aaa|bb|ccccdd|e |
> > +----+--+--------+------+---+--+------+--+
> > |1111|22|33333444|555556|7  |8 |1111  |22|
> > +----+--+--------+------+---+--+------+--+
> > 
> > As visible in the output, the 'dd' got stuck to the 'cccc' reducing the
> > number of data points.
> > 
> > Similarly between the 3's & 4's and 5's & 6's.
> > 
> > Maybe this is a naive (and buggy!) way of working with data.
> > 
> > Any suggestions?
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to