If you break down what's happening inside the function with your example:
1 2{arg
+------+-+
|266239|1|
+------+-+
>1 2{arg
266239
1
".>1 2{arg
266239 1
So this vector gets boxed and put into both places. If you allow for
multiple elements in "x", you might do something like this:
(".&.>1 2{arg) (1 2)}arg
+-----+------+-++
|ALPHA|266239|1||
+-----+------+-++
So,
numerize =: 13 : '(".&.>x{y)(x)}y'
([: {. 0 $ ]) &.> 1 2 numerize arg NB. Show 0 for numeric, ' ' for
character arguments.
+-+-+-+-+
| |0|0| |
+-+-+-+-+
On Sun, Dec 22, 2013 at 3:22 PM, Ricardo Forno <[email protected]>wrote:
> I have this little function:
> numerize =: 13 : '(<".x{>y)x}y'
> It makes numeric the contents of the xth box of the y argument. For
> example, let b:
> b
> ┌─────┬──────┬─┐
> │ALPHA│266239│1│
> └─────┴──────┴─┘
>
> 1 numerize b makes numeric the middle box.
> Why does it not work with the last two elements of b, namely:
> 1 2 numerize b
> but instead inserts a 2.element vector in each of the boxes 1 and 2?
> Thanks.
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
--
Devon McCormick, CFA
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm