ativePath`, and
>> should that be in std.path?
>>
>> ```
>> auto a="/a/b/c.d";
>> auto b="b/c.d";
>> assert(inverseRelativePath(a, b) == "/a");
>> assertThrown(inverseRelativePath(a, "c2.d"));
>> ```
>
> I
lativePath(a, b) == "/a");
> assertThrown(inverseRelativePath(a, "c2.d"));
> ```
I've never heard of inverse relative paths, but it looks like all you're
doing is looking for a substring match at the end and returning the parts at
the front that don't match. If you
how about:
```
string inverseRelativePath(string root, string rel){
while(true){
if(rel.empty || rel==".") {
return root;
}
auto a1=root.baseName;
auto a2=rel.baseName;
enforce(a1==a2, text(root, " ", rel));
root=root.dirName;
rel=rel.dirName;
}
}
unittest{
import std.exception;
auto a="/a/b/c.d";
what would be a robust way to do this `inverseRelativePath`, and
should that be in std.path?
```
auto a="/a/b/c.d";
auto b="b/c.d";
assert(inverseRelativePath(a, b) == "/a");
assertThrown(inverseRelativePath(a, "c2.d"));
```
On Wed, 25 Feb 2015 17:40:31 -0800, Andrei Alexandrescu wrote:
> Since you're here, do you plan to fix stable sort as recently discussed?
> -- Andrei
it's not necessarily so fubared as article says. i ported their java "bad
case" generator and wasn't able to hit the bug with arrays up to
1_807_
y one would have to create a whole
compositional system. e.g., @linear, @nonlinear, @additive,
@commutative, etc...
e.g., if we new foo was linear then we could simplify the above
to foo(x).
...and, as you hinted at, most functions are non-linear and
therefor will make @inverse nearly useless.
That alm
On Thursday, 26 February 2015 at 01:40:32 UTC, Andrei
Alexandrescu wrote:
Since you're here, do you plan to fix stable sort as recently
discussed? -- Andrei
While the fix seems straightforward, I haven't taken the time to
study the problem. I plan to do so and if I feel confident that I
can f
certain
redundant operations even if they are located inside a
library(i.e. no source).
A little pseudo-code for illustrational purposes, in case my
above text is incomprehensible:
void inc() pure nothrow @inverse(dec)
void dec() pure nothrow @inverse(inc)
void swap(T)(ref T lhs, ref T rhs
even
if they are located inside a library(i.e. no source).
A little pseudo-code for illustrational purposes, in case my above
text is incomprehensible:
void inc() pure nothrow @inverse(dec)
void dec() pure nothrow @inverse(inc)
void swap(T)(ref T lhs, ref T rhs) pure nothrow @inverse(swap!T)
I
library(i.e. no source).
A little pseudo-code for illustrational purposes, in case my
above text is incomprehensible:
void inc() pure nothrow @inverse(dec)
void dec() pure nothrow @inverse(inc)
void swap(T)(ref T lhs, ref T rhs) pure nothrow @inverse(swap!T)
I like the idea but feel that
Short messy recent attempt at implementing some things like this
at a library level:
https://github.com/evenex/atl/blob/master/source/main.d
if they are located inside a library(i.e. no source).
>
> A little pseudo-code for illustrational purposes, in case my above
> text is incomprehensible:
>
> void inc() pure nothrow @inverse(dec)
> void dec() pure nothrow @inverse(inc)
>
> void swap(T)(ref T lhs, ref T r
illustrational purposes, in case my
above text is incomprehensible:
void inc() pure nothrow @inverse(dec)
void dec() pure nothrow @inverse(inc)
void swap(T)(ref T lhs, ref T rhs) pure nothrow @inverse(swap!T)
13 matches
Mail list logo