Walter Bright:

import std.algorithm, std.stdio;
int main(string[] args) {
  return cast(int)args.map!("a.length").reduce!"a+b"();
}

Here's what LDC produces (with -O -inline -release -noboundscheck)

Part of this particular case problem is not a compiler optimizer weakness, but that autodecode problem I've been throwing (!) chairs through windows on.

There is no char auto decoding in this program, right?

Note: in Phobos now we have std.algorithm.sum, that is better than reduce!"a+b"().

Bye,
bearophile

Reply via email to