Re: Problem with map, reduce, ..

2015-06-24 Thread Adrian Matoga via Digitalmars-d-learn
On Wednesday, 24 June 2015 at 08:30:29 UTC, Adrian Matoga wrote: input.byLine() yields char[]'s as range elements, while props is (correctly) indexed by strings, i.e. immutable(char)[]. Ooops, more precisely it's because of the second argument of add() being string, but the solution above

Re: Problem with map, reduce, ..

2015-06-24 Thread Adrian Matoga via Digitalmars-d-learn
On Wednesday, 24 June 2015 at 08:18:52 UTC, Stefan wrote: I tried to refactor some existing code to use more of the functional patterns/style (map, filter, reduce, ..). The task is to read in some sort of a simple property file and present the result as an associative array. My attempt is:

Problem with map, reduce, ..

2015-06-24 Thread Stefan via Digitalmars-d-learn
I tried to refactor some existing code to use more of the functional patterns/style (map, filter, reduce, ..). The task is to read in some sort of a simple property file and present the result as an associative array. My attempt is: import std.stdio; import std.algorithm.iteration : filter,

Re: Problem with map, reduce, ..

2015-06-24 Thread Stefan via Digitalmars-d-learn
On Wednesday, 24 June 2015 at 08:33:29 UTC, Adrian Matoga wrote: On Wednesday, 24 June 2015 at 08:30:29 UTC, Adrian Matoga wrote: input.byLine() yields char[]'s as range elements, while props is (correctly) indexed by strings, i.e. immutable(char)[]. Ooops, more precisely it's because of the

Re: Problem with map, reduce, ..

2015-06-24 Thread Stefan via Digitalmars-d-learn
On Wednesday, 24 June 2015 at 09:35:35 UTC, Adrian Matoga wrote: On Wednesday, 24 June 2015 at 08:58:10 UTC, Stefan wrote: On Wednesday, 24 June 2015 at 08:33:29 UTC, Adrian Matoga wrote: [...] Thanks! That does it! Any idea how to make the 'ugly' reduce step more 'pleasant'? I.e. make it

Re: Problem with map, reduce, ..

2015-06-24 Thread Adrian Matoga via Digitalmars-d-learn
On Wednesday, 24 June 2015 at 08:58:10 UTC, Stefan wrote: On Wednesday, 24 June 2015 at 08:33:29 UTC, Adrian Matoga wrote: On Wednesday, 24 June 2015 at 08:30:29 UTC, Adrian Matoga wrote: input.byLine() yields char[]'s as range elements, while props is (correctly) indexed by strings, i.e.