Apply decrement with 12 mod, then its inverse:
   12&|&.<: 9+i.7
9 10 11 12 1 2 3


On Wed, Dec 26, 2012 at 7:13 AM, Ric Sherlock <[email protected]> wrote:

> Harvey,
> Here's an explicit verb that I think does what you ask for:
>
> modvalverb=: 4 : 0
>   'datalist offset'=. 2{.y
>   modval=. x
>   mm=. modval | offset + i.#datalist
>   mm=. (0 = mm)} mm,:modval
> )
>
>    12 modvalverb (i.7); 9
> 9 10 11 12 1 2 3
>
> I'm not sure what the point of giving a datalist is though since the only
> thing that gets used from it is the number of items in the list.
>
>
> On Tue, Dec 25, 2012 at 9:49 AM, PackRat <[email protected]> wrote:
>
> > I have need for a verb like residue | but which returns the mod value
> > instead of 0.  For example, instead of 9 10 11 0 1 2 3 4... for a mod
> > value of 12, it will return 9 10 11 12 1 2 3 4....  I can do it easily
> > for a single datum, but I can't see how to do it in one fell swoop for
> > a whole list of data.
> >
> > I have specific applications in mind, so the verb needs to look
> > something like this:  modvalue verb datalist;offset  (although the
> > modvalue x argument could just as easily be among the y arguments).
> >
> > A specific example might be:   12  verb  datalist;9
> > This would return the values in the first paragraph above.
> >
> > I had been thinking along these lines:
> >
> >    mm=. modval | (offset + i.(#datalist))
> >    if. 0 = mm do. mm=. modval end.
> >
> > But this, of course, does not work.
> >
> > I would appreciate explicit code only; no tacit expressions.  Much
> > thanks in advance!
> >
> >
> > Harvey
> >
> > ----------------------------------------------------------------------
> > 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
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to