splitter, compilation issue

2015-10-27 Thread sigod via Digitalmars-d-learn
Here's simple code: import std.algorithm; import std.array; import std.file; void main(string[] args) { auto t = args[1].readText() .splitter('\n') .filter!(e => e.length)

Re: splitter, compilation issue

2015-10-27 Thread sigod via Digitalmars-d-learn
Well, problem boils down to `splitter` having a greater constraints than most functions can meet. Thanks everyone for clarification. P.S. Maybe I should repost my question on SO? I really thought it was a bug, so I posted it here.

Re: splitter, compilation issue

2015-10-27 Thread Ali Çehreli via Digitalmars-d-learn
On 10/27/2015 02:55 PM, Adam D. Ruppe wrote: On Tuesday, 27 October 2015 at 21:45:10 UTC, Ali Çehreli wrote: split's documentation says that it requires a ForwardRange but the output of filter is an InputRange. (I can't imagine now why split has that requirement.) You need to .save at the

Re: splitter, compilation issue

2015-10-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 27 October 2015 at 21:45:10 UTC, Ali Çehreli wrote: split's documentation says that it requires a ForwardRange but the output of filter is an InputRange. (I can't imagine now why split has that requirement.) You need to .save at the beginning so when you hit the split point, it

Re: splitter, compilation issue

2015-10-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 27 October 2015 at 22:18:55 UTC, sigod wrote: P.S. Maybe I should repost my question on SO? I really thought it was a bug, so I posted it here. You could, but I'd say the same thing there - it is no bug, the algorithm legitimately needs that functionality to split successfully.

Re: splitter, compilation issue

2015-10-27 Thread sigod via Digitalmars-d-learn
On Tuesday, 27 October 2015 at 22:33:32 UTC, Adam D. Ruppe wrote: On Tuesday, 27 October 2015 at 22:18:55 UTC, sigod wrote: P.S. Maybe I should repost my question on SO? I really thought it was a bug, so I posted it here. You could, but I'd say the same thing there I don't expect different

Re: splitter, compilation issue

2015-10-27 Thread Ali Çehreli via Digitalmars-d-learn
On 10/27/2015 01:58 PM, sigod wrote: Here's simple code: import std.algorithm; import std.array; import std.file; void main(string[] args) { auto t = args[1].readText() .splitter('\n') .filter!(e => e.length)

Re: splitter, compilation issue

2015-10-27 Thread sigod via Digitalmars-d-learn
On Tuesday, 27 October 2015 at 21:54:33 UTC, Jonathan M Davis wrote: Well, split calls splitter, and it doesn't make much of an attempt to check its arguments in its template constraint, mostly passing the buck onto splitter, since it's really just a wrapper around splitter that calls array on

Re: splitter, compilation issue

2015-10-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 27, 2015 20:58:56 sigod via Digitalmars-d-learn wrote: > Here's simple code: > > import std.algorithm; > import std.array; > import std.file; > > void main(string[] args) > { > auto t = args[1].readText() > .splitter('\n') > .filter!(e =>

Re: splitter, compilation issue

2015-10-27 Thread sigod via Digitalmars-d-learn
On Tuesday, 27 October 2015 at 21:45:10 UTC, Ali Çehreli wrote: On 10/27/2015 01:58 PM, sigod wrote: Here's simple code: import std.algorithm; import std.array; import std.file; void main(string[] args) { auto t = args[1].readText()

Re: splitter, compilation issue

2015-10-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 28 October 2015 at 00:07:23 UTC, sigod wrote: Only removed `filter` from code. You know, I was just writing an answer for this and I kinda changed my mind. Without filter... I think splitter.splitter ought to work. The implementation requires slicing unless you pass it a

Re: splitter, compilation issue

2015-10-27 Thread sigod via Digitalmars-d-learn
On Tuesday, 27 October 2015 at 22:56:07 UTC, sigod wrote: On Tuesday, 27 October 2015 at 22:33:32 UTC, Adam D. Ruppe wrote: On Tuesday, 27 October 2015 at 22:18:55 UTC, sigod wrote: P.S. Maybe I should repost my question on SO? I really thought it was a bug, so I posted it here. You could,