Suggestion for implementation of infix 'map' and 'apply'



Hello,

On Mon, Jan 19, 2009 at 06:26:02PM +0100, ?iga Lenar?i? wrote:
> Hi!
> 
> I have another suggestion regarding infix versions of map an apply.  
> Infix notation is in many cases easier for humans to read than  
> prefix. Consider
> plus(a,b,c) vs a + b + c.
> Maxima functions 'map' and 'apply' are very common in maxima code and  
> infix versions would help improve readability and reduce the number  
> of () in the code. Consider
> map( lambda([x], x+1), [1,2,3,4]) vs
> lambda([x],x+1) /@ [1,2,3,4].

For me the first form is *far* more readable (and it has a
robust syntax where I don't need to worry).

> I know that it's easily implemented into maxima via 'infix()', and I  
> have done so with mathematica's "//" infix operator:
> infix("//")$
> "//"(expr, func) := func(expr)$
> 
> It works nicely. However I don't like the fact that a highly  
> customised 'maxima-init.mac' lead to somewhat unportable code - I  
> can't send my code to friends and expect to work in an out-of-the-box  
> maxima.
> Therefore I suggest, that such infix operators are introduced into  
> maxima - if everyone agrees of course.

I am rather sceptical about that: Obviously (see above) I don't see
value in infix-operations, but additionally for my usage at least
Maxima already pays too much attention to (for my understanding)
bad practice coming from "mathematical usage".

And the use of little symbols I regard already as bad practice on paper
(since it only works for a small world, and you necessarily exclude most others, 
who (by definition) are not familiar with such insider jargon), and definitely 
in a bigger context like Maxima, which shall be used for many things, 
the explicit(!) expressive power of language is important.

>

> The other day I was thinking of making lambda expressions shorter,  
> something like this:
> (_ + 1)& -> lambda([x], x + 1) and (_1 + _2 + 1)& -> lambda([x,y], x  
> + y + 1)
>

>From my point of view (using Maxima as a programming language, not
as a kind of front-end) Maxima is already fragile enough, so I'm
sceptical about the value of such syntactic sugar.

Sure, it depends on the usage and the users, but that's my point of view.

Oliver

P.S. Perhaps you want to provide a package with such facilities?