D2 map trouble
Nick Sabalausky
a at a.a
Tue Jul 27 16:06:18 PDT 2010
"Nick Sabalausky" <a at a.a> wrote in message
news:i2no7g$euv$1 at digitalmars.com...
> Trying to convert some D1 code to D2:
>
> On 2.047, I'm trying to do this:
>
> import std.string;
> void foo(string str)
> {
> str =
> std.algorithm.map!(
> (char a) { return inPattern(a, [digits, letters])? a : '_'; }
> )(str);
> }
>
> And I'm getting:
>
> delegate std.algorithm.__dgliteral1 cannot access frame of function
> __dgliteral1
>
> What's going on? How do I do it right? I figure I probably have some sort
> of problem with strings being immutable(char)[] instead of char[], but it
> doesn't look like that's the issue it's complaining about. Also, in this
> particular case, I'm not concerned about multi-unit UTF-8 characters.
>
>
In my particular case, I've just switched to regex:
import std.regex;
str = replace(str, regex("[^a-zA-Z0-9]"), "_");
But I am still curious to hear what exactly was going on with map.
More information about the Digitalmars-d-learn
mailing list