Raul wrote:
>Or, since the leading zero is irrelevant (and was
>not an official part of the original algorithm):
>   #:

I considered this approach, but I concluded it evades the spirit of the
algorithm.  

Ethiopian multiplication is an approach used by humans to multiply
inconveniently large numbers.  As such, its "implementation" should be
realizable by a human.  

A human (incapable of multiplying inconveniently large numbers) is
incapable of calculating  #:  (of similarly inconveniently large numbers).
 Or, put another way,  <....@-:^:a:  is the way a human would calculate  #:  .

>  emul=: p.&2@([ * |....@#:@])

We can trim 3 words from this:

    p.&2@(* |....@#:)

I'm impressed by  p.&2  .  I had come up with  #:  (as I mentioned), but
couldn't find a way to "exclude the zeros" without filtering, using  #  . 
I had tried   #.  , being obviously related, but of course that doesn't
work.

I believe that  p.&2  is in the spirit of the challenge.  Considered one
way, it's "evaluate a polynomial at 2"; at first blush, this does not
appear to be an operation a multiplication-shortcutter could realize. 
However, drilling deeper, we realize "evaluating a polynomial at 2" is
precisely steps 3-5 but expresses it concisely.  Which is the goal.

-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to