Restricting against p. is too much constraint. p. *must* be implemented with Horner's rule.
If not,

hornersRule =: [: +`*/ [: }. [: , ,.~
assert (-.+:8?@#0) (hornersRule -: p.) 3

Date: Tue, 5 Aug 2014 09:49:40 -0400
From: Dan Bron<[email protected]>
To:[email protected]
Subject: Re: [Jprogramming] Power for the powerless
Message-ID: <PC1993201408050949400080597fc8b8@DNYCW000013>
Content-Type: text/plain; charset=iso-8859-1

Raul wrote:
>   A really simple approach would be to use T.
>     pow=: ^ T. 99
First: probably a better name for your function is "exp" instead of "pow"
("exp" is a monad related to the dyad "pow" by fixing its left argument to
1x1).

But certainly exp is a welcome improvement over my formulation, with a
couple caveats. Specifically, even if we write off the presence of the
primitive ^ in ^T.99 as permissible due to the use-mention distinction,
the result of T., as you point out:

>  gives you a polynomial expression
i.e., is an expression involving p., which is not one of the specifically
enumerated operations. More problematic, it has an implicit use of ^ (the
DoJ explicitly defines x p. y  as  +/x*y^i.#x).  This is why I explicitly
excluded T.'s

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

Reply via email to