I'm not sure I'm understanding the problem correctly because I don't
see how your solution that proposes a 2nd left argument to ". would
work for empty cells surrounded by non-empty ones.

Will this not work?
   ]tst=: a: (<1 1)} 3 4$ 8!:0] 99 3 2 3 88 3 98 _48 330 3.49 0.398
┌───┬────┬─────┬───┐
│99 │3   │2    │3  │
├───┼────┼─────┼───┤
│88 │    │98   │-48│
├───┼────┼─────┼───┤
│330│3.49│0.398│99 │
└───┴────┴─────┴───┘
   _99 ". > tst
 99    3     2   3
 88  _99    98 _48
330 3.49 0.398  99


How does the data get into the boxed array? It may be possible to
convert it prior to that.
Are the contents of each box in the array either empty or a string
representing a single numeric value?

On Wed, Jan 12, 2011 at 4:46 AM,  <richard.vaug...@us.thewg.com> wrote:
> I need a simple utility that will return the numeric value represented by
> a string y, following the rules of dyadic ". except returning the scalar x
> if y is empty.  This should be fast since it is to be applied under > to
> large arrays of boxed strings whose exact format cannot be controlled.  I
> have observed that if y is preceded by a TAB the result of ". is
> unchanged, and if y is a TAB alone the result is x; therefore adding a TAB
> before (each) y seems to do the trick.  But this is not documented in the
> Vocabulary.  Can I trust this behaviour to continue in future editions of
> J?
>
> Adding a space would seem more natural but ". treats y that is all spaces
> like an empty vector.  Best would be if the left argument to ". had an
> optional second element, specifying the exact number of elements to be
> returned in each row, or default 0 for the present behaviour.  Then I
> could force an empty y to receive the padding value 0{x.
>
> Thanks,
>
> Richard Vaughan
> ----------------------------------------------------------------------
> 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