You're right that it's buggy, because as Raul and Pascal have hinted at,
'a' is acting as a 0
-- so each string is implicitly preceded by an 'a'. Another consequence
is that any password
beginning with an 'a' will be beheaded:
inc 'z' NB. 'z' equivalent to 'az'
ba
inc 'axyz' NB. beheaded
xza
One fix is to hardcode the number of letters:
inc=: >:&.(26 26 26 26&#.)&.(alpha&i.)
inc 'axyz'
axza
On 12 Dec 2015, at 14:49, Geoff Canyon wrote:
On Fri, Dec 11, 2015 at 6:56 PM, Ryan Eckbo <ec...@cim.mcgill.ca>
wrote:
inc=: >:&.(26&#.)&.(alpha&i.)
I get:
inc 'a'
b
inc 'z'
ba
inc 'y'
z
And my grasp of J isn't strong enough to figure out why. I came up
with
this alternative that seems to work:
inc =: ((26&|)@>:)&.(alpha&i.)
Perhaps that could be simplified.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm