[Issue 4111] Foreach ranges accept floating-point extrema

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 22 02:09:10 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4111



--- Comment #1 from bearophile_hugs at eml.cc 2010-04-22 02:09:06 PDT ---
Aelxx (aelxx at yandex dot ru) suggests:

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.

------------------------

My answer:

Phobos has iota() that's similar to what you ask, a FP version is easy to
create. With iota even the current interval syntax becomes less useful.
See also bug 4112.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list