<div class="gmail_quote">On Mon, Jul 19, 2010 at 21:23, Andrei Alexandrescu <span dir="ltr"><<a href="mailto:SeeWebsiteForEmail@erdani.org">SeeWebsiteForEmail@erdani.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
What I personally would like is a way to find an element in an ordered<br>
container (binary tree...)<br>
</div></blockquote>
<br>
Wouldn't that be a member of the binary tree?<br></blockquote><div><br>Yes, indeed. Unless I define some cousin to range, a recursive range, to iterate on any recursive container, like trees or graphs and then devise algorithms on them. I played with this idea a few weeks ago but went to do other things. Anyway, carry on. <br>
Btw, I still plan to update some simple generic graphs and trees structs to obey TotalContainer interface when it makes sense, and update my graph algorithms accordingly. If I ever get somewhere, I'll post something.<br>
<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
Aren't such scenarios better served by putting the limits inside the<br>
predicate? Otherwise the list of what can be done could go on forever.<br>
<br>
<br></div><div class="im">
The problem is that, as the predicate is passed at compile-time, the<br>
limits must be CT-defined too. I'd like the limits to be defined at<br>
runtime. I run into this regularly, while using predicates in<br>
std.algorithms.<br>
</div></blockquote>
<br>
I think this is a misunderstanding. All of std.algorithm works with delegates:<div class="im"><br>
<br>
int[] a = [ 1, 4, 2, 3 ];<br></div>
int b = 2;<br>
assert(find!((x) { return x > b; })(a) == [4, 2, 3]);<div class="im"><br></div></blockquote><div>Ah yes, but I regularly use algorithms structs as return values, like this:<br><br>auto nTimes(E, R)(E multiplier, R range)<br>
{<br> return map!((ElementType!R e) { return e*multiplier;})(range);<br>}<br><br>Error: delegate std.algorithm.__dgliteral2 cannot access frame of function __dgliteral2|<br><br>I ran into this yesterday while trying to encode power series as (possibly infinite) ranges, and getting problems for the operators overloading. Too bad, I got to the point where I could calculate sin/cos/exp values quite precisely and then could easily define derivation and such. There are workaround, but they are not as handy.<br>
I had the same problems some time ago, trying to define predicates on the fly, though I cannot right now remember what it was.<br><br>I know it's not a problem in std.algorithm per se, but it's a limit on its usefulness, as far as I'm concerned.<br>
<br><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Anything that can mimic regex functions on generic ranges is good, IMO.<br>
I regularly find myself wanting to do some regex-like matching. We do<br>
not need real pattern matching but even with simplified predicates, we<br>
can do many things.<br>
</blockquote>
<br></div>
I agree we're in desperate need for a good range-based, character-divorced, statically-computed regex engine.</blockquote><div><br>Oh, a full statically computed engine would be the Graal. But I did not go that far. Being able to simply match, split and replace at runtime on any range would be good also, without going all regex. Heck, I may even have already coded something like this, I'll go and check.<br>
<br>What I'm trying to do right now as a back-burner task is a function transforming a range in a set-like range (each element is present only once), but testing for "did I already see that?" with a user-provided predicate.<br>
<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I'm sorry I didn't look at your implementation, as I don't know<br>
Boyer-Moore that much. Does it need to know the alphabet size or do you<br>
use another variant?<br>
</blockquote>
<br></div>
My explanation of B-M would do little more than pasting information from various places on the Net.<br></blockquote><div><br>OK.<br><br><br>Philippe<br></div></div>