Thanks. But it now fails with length error when calling numerize with a vector left argument:

numerize =: 13 : '(".&.>x{y)x}y'
.............................................
z =: t =. cutopen each ,&' ' each t
t =. 1 2 numerize each t
where z is something like:
┌────────────────┬───────────────┬───────────────┐
│┌─────┬──────┬─┐│┌────┬──────┬─┐│┌──────┬────┬─┐│
││ALPHA│266239│1│││BETA│270271│1│││BROKEN│9288│2││
│└─────┴──────┴─┘│└────┴──────┴─┘│└──────┴────┴─┘│
└────────────────┴───────────────┴───────────────┘
|length error: readpars
|   t=.1 2     numerize each t

----- Original Message ----- From: "Devon McCormick" <[email protected]>
To: "J-programming forum" <[email protected]>
Sent: Monday, December 23, 2013 12:11 AM
Subject: Re: [Jprogramming] A little question


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

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

Reply via email to