You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
defadd(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.
The text was updated successfully, but these errors were encountered: