[Issue 4111] New: Foreach ranges accept floating-point extrema

Aelxx aelxx at yandex.ru
Wed Apr 21 23:42:52 PDT 2010


>    foreach(i; 2.1 .. 4.10001) {
>        writeln(typeid(typeof(i))); // Output: double
>        break;
>    }

I'd like MATLAB style more:
foreach (f; linspace (0.0, 1.0, 100))
{...}
here f gets values 0, 0.0101.., 0.0202..., ..., 0.98989..., 1.0

foreach (f; logspace (1.0, 1e6, 7))
{...}
here f gets values 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6. 




More information about the Digitalmars-d-bugs mailing list