lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sat, Nov 27, 2010 at 12:49:52AM +0200, Doug Lua wrote:
> 
>    \x,y,z(x*y+z)    --> function(x,y,z) return x*y+z end
> 
> It's concise and seems to have the fewest (zero?) ambiguities.
> 
I'm starting to get the hang of this discussion.  Nobody really 
takes it seriously, but it's hard to resist the temptation to 
chip in.  Even I, who think there is zero chance of the developers 
implementing anything seen so far, now succumb.

If all you want is a concise notation for mapping an m-tuple
of variables to an n-tuple of expressions, the standard way to 
do it in mathematics is
    $$  (a,b,c,d) \rightarrow (f,g,h) $$
(sorry for the TeX, but the Lua community will very shortly be
swelled by thousands of TeX users once LuaTeX is the standard).

The ASCII representation for that, taking into account that Lua 
represents an m-tuple as a table, is
    {a,b,c,d}->{f,g,h}
C programmers will have to suppress their instincts, but otherwise
it's not that unreadable.

In a numerical mathematics library, I might just be willing
to think of something like
    integral, error = integrate({x}->{1/(1+x^4)},0,1)
as actually quite neat.

I'm not qualified to judge whether dropping the braces when m=1
or n=1 will complicate matters for the parser. 

Dirk