return types of std.functional functions

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Oct 12 08:27:14 PDT 2014


On 10/12/2014 08:04 AM, yawniek wrote:
> i found two snippets from the functional docs that do not work (anymore?)
> http://dlang.org/phobos/std_functional.html
>
>
> assert(compose!(map!(to!(int)), split)("1 2 3") == [1, 2, 3]);
> and
> int[] a = pipe!(readText, split, map!(to!(int)))("file.txt");
>
> throwing a std.array.array into the mix works fine.
>
> did this use to work? is there any other way of doing it?

The proper way is to call std.algorithm.equal, which compares ranges 
element-by-element:

     assert(compose!(map!(to!(int)), split)("1 2 3").equal([1, 2, 3]));

Ali



More information about the Digitalmars-d-learn mailing list