[Issue 13958] RangeError with impure map
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Jan 9 07:46:04 PST 2015
https://issues.dlang.org/show_bug.cgi?id=13958
bearophile_hugs at eml.cc changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bearophile_hugs at eml.cc
--- Comment #1 from bearophile_hugs at eml.cc ---
The short answer: do not use impure functions in higher order functions like
map/filter, unless you know what you are doing (and you usually don't).
So it's better to find a pure way to solve your problem, like:
void main() {
import std.stdio, std.algorithm, std.array, std.range;
static a = ["a", "b", "c", "d", "e", "f", "g", "h", "i"];
zip(a, a).map!(p => p[0] ~ p[1]).joiner(", ").writeln;
}
--
More information about the Digitalmars-d-bugs
mailing list