Newsgroups: comp.lang.apl
Path: watmath!watserv1!utgpu!news-server.csri.toronto.edu!rpi!think.com!ames!haven.umd.edu!socrates!socrates!rockwell
From: rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell)
Subject: Re: Expressiveness of Language
In-Reply-To: liberte@cs.uiuc.edu's message of Fri, 20 Mar 1992 23:32:38 GMT
Message-ID: <ROCKWELL.92Mar21003041@socrates.umd.edu>
Sender: rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell)
Organization: Traveller
References: <1992Mar19.190314.27860@csi.jpl.nasa.gov> <1992Mar19.220251.29999@cshl.org>
	<ROCKWELL.92Mar20072450@socrates.umd.edu>
	<1992Mar20.184205.4943@watmath.waterloo.edu>
	<LIBERTE.92Mar20173238@birch.cs.uiuc.edu>
Date: Sat, 21 Mar 1992 05:30:41 GMT

Daniel LaLiberte:
   One important problem for an APL notation (to remain anything close
   to the original APL concept) is to treat user defined functions in
   the same way as infix and prefix operators.  Smalltalk has relevant
   ideas here.  Functional languages have ideas for notations of
   operating on functions as objects.

This may be an important problem, but it's also a solved problem.
J has some extremely powerful functional concepts built into its
notation.

To address some of the comments I've seen in this newsgroup in the
last couple days...  If you wish to guarantee that a function is only
used monadically, you can use
        fn : ''

Likewise, if you wish to guarantee that the function is only used
dyadically, you can use
        '' : fn

Armed with this piece of information, here's a routine to multiply two
'polynomials' [represented as vectors of coefficients]:

        sum=:  +/ : ''              NB. insert '+' between elements of arg
        fan=:     /.                NB. operator: apply fn on diagonal slices
        op=:   '' : (*/)            NB. outer product

        product=: sum fan X op Y    NB. multiply polynomials

Here, 'X' and 'Y' represent vectors, and 'product' is also a vector.
Alternatively, you could say:

        compose=:  @:                   NB. chain functions together
        Prod=:  sum fan   compose op    NB. polynomial product

In this case, Prod is a function, and
        product=: X Prod Y
should give you the same result as before.

-- 
Raul Deluth Miller-Rockwell                   <rockwell@socrates.umd.edu>
