On Sat, May 07, 2005 at 01>00>08PM -0700, Larry Wall wrote: > On the other hand, since we've distinguished hyperops on > infixes from hyperops on unaries, maybe an infix hyperop in > unary position just does the thing to itself: > > @squares = Â*Â @list; > > which gives us a sum-of-squares that looks like this: > > @sumofsquares = [+] Â*Â @list;

> On the gripping hand, I can't think of any other operators I'd > be likely to want to do that to, Ken Iverson had the same problem in the beginning. http://www.vector.org.uk/typography/pview.htm "Even after tasting the fruits of generalizing the Î notation of mathematics to the form f/ that permitted the use of functions other than addition, it took some time before I recognized the advantages of a corresponding generalization of the inner or matrix product to allow the use of functions other than addition and multiplication." > so forget it. Not worth teaching people. In languages that have reduce, scan, and inner product, it turns out that there are a number of other useful cases besides sum and sum of products. Minimax and maximin in game theory, for example. Boolean inner products on incidence matrices give a result showing which points are connected by paths of length two, and higher powers give connectedness on paths of length 'n', up to the point at which all path-connected components have been completely identified. 'And of equals' matches vectors (lists) against rows or columns of a table, depending on the order of the arguments. There are a number of others in the literature, some of them quite common in use. Once reduce, scan, and inner product can apply to user-defined functions, the possibilities open wide. Scan is an extension of reduce. It takes every initial segment of its vector argument, and does a reduce on it. (For right-to-left evaluation as in APL and J, this requires order N squared time on non-commutative functions.) J has extended scan to a version that operates on final segments. Examples at file:///usr/share/j504/system/extras/help/dictionary/intro14.htm This paper applies scans to inner product functions. http://portal.acm.org/citation.cfm?id=882077 The inner-product scan allows a straight-forward calculation of interest-bearing accounts or annuities without a loop in APL. > Larry -- Edward Cherlin Generalist & activist--Linux, languages, literacy and more "A knot! Oh, do let me help to undo it!" --Alice in Wonderland http>//cherlin.blogspot.com