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



>>>>> "ziga" == ziga lenarcic <iga> writes:

    ziga> Hi!
    ziga> I have another suggestion regarding infix versions of map an apply.  
    ziga> Infix notation is in many cases easier for humans to read than  
    ziga> prefix. Consider
    ziga> plus(a,b,c) vs a + b + c.
    ziga> Maxima functions 'map' and 'apply' are very common in maxima code and  
    ziga> infix versions would help improve readability and reduce the number  
    ziga> of () in the code. Consider
    ziga> map( lambda([x], x+1), [1,2,3,4]) vs
    ziga> lambda([x],x+1) /@ [1,2,3,4].

I agree that the later is slightly easier to read.

[snip]

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

[snip]

    ziga> benefit maxima code. For instance - to square every list entry and  
    ziga> make it a matrix and transpose would in such notation be:
    ziga> ( 'matrix @@ (_^2)& /@ [1,2,3,4] ) // transpose  vs
    ziga> transpose(apply('matrix,map(lambda([x],x^2),[1,2,3,4])))

I have to say that these later examples are extremely hard for me to
read.

But maybe that's because I have not been polluted by Mathematica but I
am polluted by Lisp.

Ray