Re: function for inverse relative path?

2017-12-07 Thread Timothee Cour via Digitalmars-d
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

Re: function for inverse relative path?

2017-12-06 Thread Jonathan M Davis via Digitalmars-d
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&#

Re: function for inverse relative path?

2017-12-06 Thread Timothee Cour via Digitalmars-d
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";

function for inverse relative path?

2017-12-06 Thread Timothee Cour via Digitalmars-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")); ```

Re: @inverse

2015-02-25 Thread ketmar via Digitalmars-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_

Re: @inverse

2015-02-25 Thread Xinok via Digitalmars-d
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

Re: @inverse

2015-02-25 Thread Xinok via Digitalmars-d
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

Re: @inverse

2015-02-25 Thread Sativa via Digitalmars-d
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

Re: @inverse

2015-02-25 Thread Andrei Alexandrescu via Digitalmars-d
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

Re: @inverse

2015-02-25 Thread Xinok via Digitalmars-d
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

Re: @inverse

2015-02-25 Thread Vlad Levenfeld via Digitalmars-d
Short messy recent attempt at implementing some things like this at a library level: https://github.com/evenex/atl/blob/master/source/main.d

Re: @inverse

2015-02-25 Thread H. S. Teoh via Digitalmars-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

@inverse

2015-02-25 Thread Daniel N via Digitalmars-d
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)