Open PhilAndrew opened 11 years ago
Have to give this one some thought...
Was originally intending to use @1
, @2
, etc. But thought on reflection that it's usually better to be a little verbose with your params anyway. For common functions, like map
and filter
that only pass one parameter for example, this sort of thing could be useful.
Yes the interesting thing is there's so many ways to do it. For example in Scala.
(1 to 1000).reduceLeft( _ + _ )
The + is a notation which produces the function (a,b) => a + b which could also be written as
def add(a,b) = {
a + b
}
(1 to 1000).reduceLeft(add)
Then you could look at LiveScript and how it chains functions together to map fold etc. With so many ways to do it, you have a problem of choice, what is going to work well with your language.
In Scala you can write.
scala> (1 until 1000).filter(n => n % 3 == 0 || n % 5 == 0).foldLeft(0)( + ) res2: Int = 233168
n => n % 3 == 0... this is a function with parameter n.
Could
Be written more concisely as something like:
I do not have any good suggestion for syntax.