Rudi Mann <[email protected]> wrote: > Hi, > > I'm having a little problem understanding this (from Viktor Cerovski's > solution): > > > > > diffdig =: *./@~:@(#.^:_1) > > > Why is a scalar left argument sufficient in this case > > (10&#.^:_1) 123 > 1 2 3 > > but when I omit the power adverb and use the inverse function directly > I need a vector to get the same result? > > 10#:123 > 3 > 10 10 10#:123 > 1 2 3 > > Isn't #:^:_1 the same as #. since they are inverse functions?
Not exactly. If you'll note the definition of #:, the dyad is rank 1 0 and gives you exactly the same number of digits as in x. However, the monad has infinite rank, because it figures out how many binary digits are needed for the widest result. If it were rank 0, the normal rank mechanism would add trailing zeros for shorter numbers, rather than leading zeros. All results of the power conjunction have infinite rank. With a list left argument, dyad #.^:_1 works just like dyad #: However, with an atomic left argument, it works like monad #: except using base x rather than base 2. Note that this definition is a more proper inverse to dyadic #. than #: is. I have no idea why dyad #: wasn't defined this way for atomic x, but it wasn't, possibly for backwards compatibility with APL. -- Mark D. Niemiec <[email protected]> ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
