"fold": a replacement for "reduce"
"Nordlöw"
per.nordlow at gmail.com
Wed Mar 26 14:32:43 PDT 2014
> a is of type double, b is of type idouble. When you consume the
> next element, the result would be double again, and it
> oscillates like that.
I guess the return is CommonType!(double,idouble) in that case,
right?
Is that so hard to figure out...Hmm, there seems to be a
limitation in D's builtin handling of complex numbers.
import std.stdio, std.algorithm, std.traits;
void main(string args[])
{
double re;
idouble im;
alias C = CommonType!(double, idouble);
C c;
writeln(typeof(re).stringof, ",", typeof(im).stringof, ",",
C.stringof);
}
prints
double,idouble,double
This is *not* what we want.
We want to print something like
double,idouble,cdouble (or Complex!double!)
I guess that's why it's deprecated in favour of std.complex...
More information about the Digitalmars-d
mailing list