[Issue 13595] New: A possible problem with std.algorithm.groupBy
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Oct 10 03:17:07 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13595
Issue ID: 13595
Summary: A possible problem with std.algorithm.groupBy
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: Phobos
Assignee: nobody at puremagic.com
Reporter: bearophile_hugs at eml.cc
Perhaps I have not fully understood the usage of std.algorithm.groupBy. This is
Haskell:
Prelude> import Data.List
Prelude Data.List> groupBy (\x y -> (mod (x*y) 3) == 0) [1,2,3,4,5,6,7,8,9]
[[1],[2,3],[4],[5,6],[7],[8,9]]
D code:
void main() {
import std.stdio, std.algorithm, std.array, std.range;
[1,2,3,4,5,6,7,8,9]
.groupBy!((x, y) => ((x * y) % 3) == 0)
.take(20)
.writeln;
}
Output of the D code:
[[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [],
[]]
Please close down this issue if this behavour is expected and correct.
--
More information about the Digitalmars-d-bugs
mailing list