[Jprogramming] A little question
Ric Sherlock
tikkanz at gmail.com
Mon Dec 23 20:57:12 UTC 2013
If you are trying to numerize any items in a boxed table that can be
numerized (rather than understand why your verb isn't working) then the
makenum verb from the tables/dsv addon may be useful:
Install 'tables/dsv' addon using package manager (if not already
installed). Then:
require 'tables/dsv'
datatype each makenum_pdsv_ 'ALPHA';'266239';'1'
┌───────┬───────┬───────┐
│literal│integer│boolean│
└───────┴───────┴───────┘
On Tue, Dec 24, 2013 at 9:33 AM, Devon McCormick <devonmcc at gmail.com> wrote:
> You have two arguments on the left but three on the right: that's why it's
> a length error. As Henry mentioned, something like "(<1 2) numerize each
> t" effectively fixes this by making the left argument a scalar, which can
> be applied to each element on the right (under disclose).
>
>
> On Mon, Dec 23, 2013 at 3:26 PM, Henry Rich <HenryHRich at nc.rr.com> wrote:
>
> > Try
> > 1 2&numerize each t
> > or
> > (<1 2) numerize each t
> >
> > Henry Rich
> >
> >
> > On 12/23/2013 11:07 AM, Ricardo Forno wrote:
> >
> >> 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" <
> devonmcc at gmail.com>
> >> To: "J-programming forum" <programming at jsoftware.com>
> >> 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
> >>> <ricardoforno at tutopia.com>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
> >>
> > ----------------------------------------------------------------------
> > 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
>
More information about the Programming
mailing list