digitalmars.D.learn - is there a difference between those two notations
- =?ISO-8859-1?Q?Christian_K=F6stlin?= <christian.koestlin gmail.com> Apr 30 2012
- "Jesse Phillips" <Jessekphillips+D gmail.com> Apr 30 2012
- "Jonathan M Davis" <jmdavisProg gmx.com> Apr 30 2012
- "bearophile" <bearophileHUGS lycos.com> Apr 30 2012
- Timon Gehr <timon.gehr gmx.ch> Apr 30 2012
reduce!((int a, int b){return a+b;})(iota(100))
reduce!("a+b")(iota(100))
thanks in advance
christian koestlin
Apr 30 2012
On Monday, 30 April 2012 at 15:19:02 UTC, Christian Köstlin wrote:reduce!((int a, int b){return a+b;})(iota(100)) reduce!("a+b")(iota(100)) thanks in advance christian koestlin
The answer to your question should be no. The second is transformed into a delegate like the first during compilation. Note that there is also C# like lambdas (a, b) => a+b
Apr 30 2012
On Monday, April 30, 2012 17:19:00 Christian Köstlin wrote:reduce!((int a, int b){return a+b;})(iota(100)) reduce!("a+b")(iota(100)) thanks in advance
The first one directly creates a lambda, whereas the second one uses a string mixin with std.function.binaryFunc to create a lambda. The lambda generated for the second one will be the same as the one given in the first. They're just different ways to do the same thing. - Jonathan M Davis
Apr 30 2012
On 04/30/2012 07:04 PM, Jonathan M Davis wrote:On Monday, April 30, 2012 17:19:00 Christian Köstlin wrote:reduce!((int a, int b){return a+b;})(iota(100)) reduce!("a+b")(iota(100)) thanks in advance
The first one directly creates a lambda, whereas the second one uses a string mixin with std.function.binaryFunc to create a lambda. The lambda generated for the second one will be the same as the one given in the first. They're just different ways to do the same thing. - Jonathan M Davis
https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm.d ... regards christian koestlin
Apr 30 2012
Christian Köstlin:reduce!((int a, int b){return a+b;})(iota(100)) reduce!("a+b")(iota(100))
Today the syntaxes I prefer are: iota(100).reduce!q{a + b}() iota(100).reduce!((a, b) => a + b)() But hopefully in some we'll have an efficient sum() function too in Phobos: iota(100).sum() Bye, bearophile
Apr 30 2012
On 04/30/2012 11:03 PM, bearophile wrote:Christian Köstlin:reduce!((int a, int b){return a+b;})(iota(100)) reduce!("a+b")(iota(100))
Today the syntaxes I prefer are: iota(100).reduce!q{a + b}() iota(100).reduce!((a, b) => a + b)() But hopefully in some we'll have an efficient sum() function too in Phobos: iota(100).sum() Bye, bearophile
i always forget about this nice d feature :) regards christian
May 02 2012
On 04/30/2012 05:19 PM, Christian Köstlin wrote:reduce!((int a, int b){return a+b;})(iota(100)) reduce!("a+b")(iota(100)) thanks in advance christian koestlin
In this case there is not. But if external symbols are to be referred to inside the lambda, then the second notation cannot be used.
Apr 30 2012









"Jesse Phillips" <Jessekphillips+D gmail.com> 