-
-
Notifications
You must be signed in to change notification settings - Fork 705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
amap() and maybe afilter() too #9900
Labels
Comments
bearophile_hugs commented on 2011-03-23T23:47:04ZAs in std.parallelism, I suggest to add a second optional argument to the amap()/afilter(), an optional buffer to return the result. If the buffer is provided, it must be the same length as the range.
So you write:
auto numbers = iota(10);
auto squareRoots = new double[numbers.length];
amap!sqrt(numbers, squareRoots);
Instead of:
auto numbers = iota(10);
auto squareRoots = new double[numbers.length];
copy(map!sqrt(numbers), squareRoots); |
bearophile_hugs commented on 2011-03-27T13:38:59ZIt seems dsimcha has renamed two functions in std.parallelism, now the eager version is named amap:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=132731 |
bearophile_hugs commented on 2011-04-12T17:19:56ZSee also bug 5838 |
bearophile_hugs commented on 2011-09-14T04:55:40ZSee here for better explanations:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=29516 |
bearophile_hugs commented on 2011-09-29T15:06:38ZAn example of amap usage. This is input data:
auto data = ["1111100000",
"1111000000",
"1110000000",
"1100001000",
"1000010000",
"0000100001",
"0001000011",
"0010000111",
"0000001111",
"0000011111"];
To convert it into a 2D matrix of booleans:
auto r = array(map!q{ array(map!q{ a == '1' }(a)) }(data));
The result r:
[[true, true, true, true, true, false, false, false, false, false], [true, true, true, ...]]
Using amap the line of code becomes shorter and less noisy, almost readable:
auto r = amap!q{ amap!q{ a == '1' }(a) }(data); |
lt.infiltrator commented on 2014-03-19T21:21:18ZWould you like to create a PR for this? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bearophile_hugs reported this on 2011-03-19T17:09:37Z
Transfered from https://issues.dlang.org/show_bug.cgi?id=5756
CC List
Description
The text was updated successfully, but these errors were encountered: