digitalmars.D - Range with lookaround
- Andrei Alexandrescu (2/2) Mar 01 2017 May be worth discussing in here:
- qznc (11/13) Mar 02 2017 I don't understand the use case. PR #5153 seems to be about
- Andrei Alexandrescu (5/17) Mar 02 2017 Yah, parsing would be an obvious application. Others such as
- Dukc (15/17) Mar 03 2017 //My understanding of the concept, is this correct?
- Dukc (2/10) Mar 03 2017
- Andrei Alexandrescu (2/3) Mar 03 2017 should be iota(5).lookaround!(1, 2)
- Dukc (4/6) Mar 03 2017 Almost similar to this: https://github.com/dlang/phobos/pull/4027
- Seb (5/12) Mar 03 2017 My PR even included such a circular buffer until Andrei suggested
- Andrei Alexandrescu (2/7) Mar 03 2017 Yes! cc @wilzbach
May be worth discussing in here: https://issues.dlang.org/show_bug.cgi?id=17238 -- Andrei
Mar 01 2017
On Thursday, 2 March 2017 at 01:44:19 UTC, Andrei Alexandrescu wrote:May be worth discussing in here: https://issues.dlang.org/show_bug.cgi?id=17238 -- Andreigetting the last element, not about some lookahead. When I think about lookahead, I always think of parsers. If the lexer provides an input range of tokens, my recursive descent parser might need 3 tokens lookahead, for example. For the lexer input a "push back a character into my input" is more convenient. Should it give some performance guarantees? I guess, we don't want to refresh the buffers at every popFront, so it would probably be as lazy as possible.
Mar 02 2017
On 3/2/17 7:51 AM, qznc wrote:On Thursday, 2 March 2017 at 01:44:19 UTC, Andrei Alexandrescu wrote:Yah, parsing would be an obvious application. Others such as adjacentFind might also benefit.May be worth discussing in here: https://issues.dlang.org/show_bug.cgi?id=17238 -- Andreilast element, not about some lookahead. When I think about lookahead, I always think of parsers. If the lexer provides an input range of tokens, my recursive descent parser might need 3 tokens lookahead, for example. For the lexer input a "push back a character into my input" is more convenient.Should it give some performance guarantees? I guess, we don't want to refresh the buffers at every popFront, so it would probably be as lazy as possible.Yah, a circular buffer should help here. Andrei
Mar 02 2017
On Thursday, 2 March 2017 at 01:44:19 UTC, Andrei Alexandrescu wrote:May be worth discussing in here: https://issues.dlang.org/show_bug.cgi?id=17238 -- Andrei//My understanding of the concept, is this correct? assert(iota(5).lookAhead(1, 2).array == [ [0, 1], [0, 1, 2], [0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4], [3, 4], [4] ]); I would prefer if the second argument meant length, not distance to look back. So the call equivalent to the one above would be lookAhead(-2, 4).
Mar 03 2017
On Friday, 3 March 2017 at 11:22:37 UTC, Dukc wrote:[snip]correction:assert(iota(5).lookAhead(1, 2).array == [ [0, 1], [0, 1, 2], [0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4] ]);
Mar 03 2017
On 3/3/17 6:22 AM, Dukc wrote:iota(5).lookAhead(1, 2)should be iota(5).lookaround!(1, 2)
Mar 03 2017
On Thursday, 2 March 2017 at 01:44:19 UTC, Andrei Alexandrescu wrote:May be worth discussing in here: https://issues.dlang.org/show_bug.cgi?id=17238 -- AndreiAlmost similar to this: https://github.com/dlang/phobos/pull/4027 Perhaps we should use that as base?
Mar 03 2017
On Friday, 3 March 2017 at 11:56:26 UTC, Dukc wrote:On Thursday, 2 March 2017 at 01:44:19 UTC, Andrei Alexandrescu wrote:My PR even included such a circular buffer until Andrei suggested to move it to a separate PR. However, I think we are all misunderstanding Andrei. He isn't referring to a buffer here - have a look at the issue.May be worth discussing in here: https://issues.dlang.org/show_bug.cgi?id=17238 -- AndreiAlmost similar to this: https://github.com/dlang/phobos/pull/4027 Perhaps we should use that as base?
Mar 03 2017
On 3/3/17 6:56 AM, Dukc wrote:On Thursday, 2 March 2017 at 01:44:19 UTC, Andrei Alexandrescu wrote:Yes! cc wilzbachMay be worth discussing in here: https://issues.dlang.org/show_bug.cgi?id=17238 -- AndreiAlmost similar to this: https://github.com/dlang/phobos/pull/4027 Perhaps we should use that as base?
Mar 03 2017