o =: 'xx'
   l =: 1 2 3 4
   v =: 4 : 'x,''_'',":y'

   o v {.l
xx_1

   v~/ o(,<)~;/|.l
|domain error: v
|   x    ,'_',":y


   >(v~&.>) / 1|.o;;/|. l
xx_1_2_3_4

Yes, boxing/unboxing works, thanks. Now will see what's faster...

G.P.

On Tue, Feb 3, 2015 at 6:46 PM, R.E. Boss <[email protected]> wrote:

> correction
>
> v~/ o(,<)~;/|.l
>
> R.E. Boss
>
>
> > -----Original Message-----
> > From: [email protected] [mailto:programming-
> > [email protected]] On Behalf Of R.E. Boss
> > Sent: dinsdag 3 februari 2015 17:43
> > To: [email protected]
> > Subject: Re: [Jprogramming] Fold/reduce with initial value?
> >
> > v~/ o;~;/|.l
> >
> > example:
> >    (-)~L:0/ (i.5)(,<)~ ;/|. i.10
> > +-------------------+
> > |_45 _44 _43 _42 _41|
> > +-------------------+
> >
> >
> > R.E. Boss
> >
> >
> > > -----Original Message-----
> > > From: [email protected]
> > [mailto:programming-
> > > [email protected]] On Behalf Of Moon S
> > > Sent: dinsdag 3 februari 2015 17:16
> > > To: [email protected]
> > > Subject: [Jprogramming] Fold/reduce with initial value?
> > >
> > > I have a list (l), some object (o) and a verb (v) modifying the object:
> > >
> > > l = l_0 l_1 ... l_n
> > > o_new = o_old v l_i
> > >
> > > The list items and the object have different types. I want to apply all
> > the
> > > list items to the object:
> > >
> > > o_new = (...((o_old v l_0) v l_1) ... v l_n)     NB. the order of items
> > > doesn't matter
> > >
> > > Currently I do it like this:
> > >
> > > o =: o_old
> > > 3 : 'o =: y v o' "0 l
> > >
> > > I suspect, there must be some built-in feature for that, like / or ^:,
> so
> > > that I could write e.g.
> > > o_new =: o_old v REDUCE l, but I couldn't find a suitable
> > > verb/adverb/conjunction.
> > >
> > > Any help?
> > >
> > > Thank you.
> > >
> > > Georgiy Pruss.
> > > ----------------------------------------------------------------------
> > > 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
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to