Re: Lazy KMP range

2012-06-15 Thread bearophile
Dmitry Olshansky: Yes, definitely just decouple table preparation and searching range itself. It's common to use KMP and its ilk to do a lot of series of searches for the same needle. OK. Regarding the license, this is a translation from another language of a basic algorithm. I don't think

Re: Lazy KMP range

2012-06-15 Thread Dmitry Olshansky
On 15.06.2012 23:41, Roman D. Boiko wrote: On Friday, 15 June 2012 at 19:03:56 UTC, bearophile wrote: A lazy Knuth-Morris-Pratt that works on a Input Range: http://ideone.com/dUs5B Do you have suggestions for improvements of the code? Maybe do I have to turn it into a Forward Range if the first

Re: Lazy KMP range

2012-06-15 Thread Roman D. Boiko
On Friday, 15 June 2012 at 19:41:35 UTC, Roman D. Boiko wrote: Pay attention to "Licensed under the PSF License" for your source implementation. You will not be able to include it into Phobos unless implementation details that you borrowed from Python implementation can be found elsewhere under

Re: Lazy KMP range

2012-06-15 Thread Roman D. Boiko
On Friday, 15 June 2012 at 19:03:56 UTC, bearophile wrote: A lazy Knuth-Morris-Pratt that works on a Input Range: http://ideone.com/dUs5B Do you have suggestions for improvements of the code? Maybe do I have to turn it into a Forward Range if the first range is a Forward one? Is something simi

Re: Lazy KMP range

2012-06-15 Thread Dmitry Olshansky
On 15.06.2012 23:03, bearophile wrote: A lazy Knuth-Morris-Pratt that works on a Input Range: http://ideone.com/dUs5B Do you have suggestions for improvements of the code? Maybe do I have to turn it into a Forward Range if the first range is a Forward one? Is something similar to this useful for

Re: Immutability and other attributes, please review

2012-06-15 Thread Roman D. Boiko
On Friday, 15 June 2012 at 10:01:42 UTC, Dmitry Olshansky wrote: Suggest you revisit toNode function as it does return something strange :) Just looking at first - last lines: pure nothrow auto toNode(R)(R range, immutable(Maybe!Node) parent) if(isInputRange!R && hasLength!R)

Re: Immutability and other attributes, please review

2012-06-15 Thread Dmitry Olshansky
On 15.06.2012 12:50, Roman D. Boiko wrote: On Friday, 15 June 2012 at 08:31:08 UTC, dennis luehring wrote: Am 15.06.2012 08:25, schrieb Jacob Carlborg: On 2012-06-14 17:32, Roman D. Boiko wrote: I agree, just looking how to accomplish my goals. I decided to get rid of casting, and will store

Re: Immutability and other attributes, please review

2012-06-15 Thread Roman D. Boiko
On Friday, 15 June 2012 at 08:31:08 UTC, dennis luehring wrote: Am 15.06.2012 08:25, schrieb Jacob Carlborg: On 2012-06-14 17:32, Roman D. Boiko wrote: I agree, just looking how to accomplish my goals. I decided to get rid of casting, and will store everything on heap. I don't know how to put

Re: Immutability and other attributes, please review

2012-06-15 Thread Jacob Carlborg
On 2012-06-15 10:30, dennis luehring wrote: i think he needs to - else he encapsulate the float into an struct which is then also on the heap (ast/whatever) nodex -> float nodey -> string nodez -> int nodew -> double etc. in this example a node can contain from n types values - how would you

Re: Immutability and other attributes, please review

2012-06-15 Thread dennis luehring
Am 15.06.2012 08:25, schrieb Jacob Carlborg: On 2012-06-14 17:32, Roman D. Boiko wrote: I agree, just looking how to accomplish my goals. I decided to get rid of casting, and will store everything on heap. I don't know how to put a variable of type float to the heap, and thought that it would b

Re: Immutability and other attributes, please review

2012-06-15 Thread Roman D. Boiko
On Friday, 15 June 2012 at 06:25:59 UTC, Jacob Carlborg wrote: On 2012-06-14 17:32, Roman D. Boiko wrote: I agree, just looking how to accomplish my goals. I decided to get rid of casting, and will store everything on heap. I don't know how to put a variable of type float to the heap, and thou

Re: Getting a range over a const Container

2012-06-15 Thread Jonathan M Davis
On Friday, June 15, 2012 09:14:45 Matthias Walter wrote: > Hi, > > I have a const std.container object (e.g., a const(Array!int)) of which > I'd like to have a range which can traverse that container having > read-only access. This does not seem to be possible with opSlice(). Is > there an alterna

Getting a range over a const Container

2012-06-15 Thread Matthias Walter
Hi, I have a const std.container object (e.g., a const(Array!int)) of which I'd like to have a range which can traverse that container having read-only access. This does not seem to be possible with opSlice(). Is there an alternative? Best regards, Matthias