digitalmars.D - Nested Inferred Templates Don't Work?
- Mehrdad (11/11) May 30 2011 Hi!
- Andrei Alexandrescu (5/16) May 31 2011 That's a bug in the compiler. You may want to try specifying the
- Mehrdad (9/29) May 31 2011 longest line
Hi! Say I've got a piece of code like this, which gives me the longest line in a file: pipe!(readText, splitlines, map!((a) { return a.length; }), reduce!max)("Demo.txt"); The problem is, it doesn't work. Which is kind of a bummer. :( Is there an **elegant** way to get around it? Of course, I already know I can do this: pipe!(readText, splitlines, map!q{ a.length }, reduce!max)("Demo.txt"); but using strings is very ugly (IMO). Thanks!
May 30 2011
On 5/31/11 1:04 AM, Mehrdad wrote:Hi! Say I've got a piece of code like this, which gives me the longest line in a file: pipe!(readText, splitlines, map!((a) { return a.length; }), reduce!max)("Demo.txt"); The problem is, it doesn't work. Which is kind of a bummer. :( Is there an **elegant** way to get around it? Of course, I already know I can do this: pipe!(readText, splitlines, map!q{ a.length }, reduce!max)("Demo.txt"); but using strings is very ugly (IMO). Thanks!That's a bug in the compiler. You may want to try specifying the function literal with types, e.g. function size_t(string a) { return a.length; }. A bug report would be appreciated. Andrei
May 31 2011
== Quote from Andrei Alexandrescu (SeeWebsiteForEmail erdani.org)'s articleOn 5/31/11 1:04 AM, Mehrdad wrote:longest lineHi! Say I've got a piece of code like this, which gives me the("Demo.txt");in a file: pipe!(readText, splitlines, map!((a) { return a.length; }), reduce!max)("Demo.txt"); The problem is, it doesn't work. Which is kind of a bummer. :( Is there an **elegant** way to get around it? Of course, I already know I can do this: pipe!(readText, splitlines, map!q{ a.length }, reduce!max)returnbut using strings is very ugly (IMO). Thanks!That's a bug in the compiler. You may want to try specifying the function literal with types, e.g. function size_t(string a) {a.length; }. A bug report would be appreciated. AndreiThat actually doesn't work either (it says it can't access the frame...). I filed a bug report: http://d.puremagic.com/issues/show_bug.cgi?id=6081 Thanks!
May 31 2011