[Jprogramming] Residue without 0 remainder

Henry Rich HenryHRich at nc.rr.com
Mon Dec 24 20:54:47 UTC 2012


I don't get what your 'offset' field is, but |&.<: might be useful:

    12 | 9+i. 7
9 10 11 0 1 2 3
    12&|&.<: 9+i. 7
9 10 11 12 1 2 3

Henry Rich

On 12/24/2012 3:49 PM, PackRat 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
>


More information about the Programming mailing list