Setting the rank of a user-defined verb in J

Posted by Gregory Higley on Stack Overflow See other posts from Stack Overflow or by Gregory Higley
Published on 2010-06-02T22:21:06Z Indexed on 2010/06/02 22:24 UTC
Read the original article Hit count: 217

Filed under:
|
|

Here's a function to calculate the digital sum of a number in J:

digitalSum =: +/@:("."0)@":

If I use b. to query the rank of this verb, I get _ 1 _, i.e., infinite. (We can ignore the dyadic case since digitalSum is not dyadic.)

I would like the monadic rank of this verb to be 0, as reported by b.. The only way I know of to do this is to use a "shim", e.g.,

ds =: +/@:("."0)@":
digitalSum =: ds"0

This works great, but I want to know whether it's the only way to do this, or if there's something else I'm missing.

© Stack Overflow or respective owner

Related posts about beginner

Related posts about tacit-programming