On Saturday, 23 August 2014 at 18:07:43 UTC, Fool wrote:
[2] http://dpaste.dzfl.pl/514a1ef77d0a
The 'three reverses' algorihm could be actually improved. Updated
code (along with additional unit tests and a strengthened
assertion) is available at [3].
I compared this implementation to an
There was a bug in my C++ translation of rotateTail. The only
significant change in execution time is marked below:
On Sunday, 24 August 2014 at 09:20:59 UTC, Fool wrote:
compiler | algorithm| execution time
--+--+
clang++ |
After having some fun with rotateTail and friends a draft
implementation [2] is now available and ready for comments aiming
at formal specification, algorithmics, and implementation details.
While most ideas were taken from [1], all mistakes are mine.
Since this is my first D code, more or
On Monday, 11 August 2014 at 14:45:09 UTC, Andrei Alexandrescu
wrote:
On 8/11/14, 2:11 AM, Nordlöw wrote:
On Monday, 11 August 2014 at 06:56:52 UTC, Dragos Carp wrote:
bool sliceOf(T)(in T[] whole, in T[] slice)
{
return whole.ptr = slice.ptr
whole.ptr + slice.length = whole.ptr +
On Monday, 18 August 2014 at 05:27:11 UTC, Andrei Alexandrescu
wrote:
On 8/17/14, 9:06 AM, Fool wrote:
http://dpaste.dzfl.pl/8fc83cb06de8
Yah, it's a good option. Relevant code:
if (right is whole)
{
//writeln(case identical);
return tuple(right, whole.dropExactly(whole.length));
}
On 8/19/14, 12:32 PM, Fool wrote:
On Monday, 18 August 2014 at 05:27:11 UTC, Andrei Alexandrescu wrote:
On 8/17/14, 9:06 AM, Fool wrote:
http://dpaste.dzfl.pl/8fc83cb06de8
Yah, it's a good option. Relevant code:
if (right is whole)
{
//writeln(case identical);
return tuple(right,
On Monday, 11 August 2014 at 03:29:56 UTC, Andrei Alexandrescu
wrote:
[...] can be implemented generically for ranges that offer
front as a reference:
bool sameFront(R1, R2)(R1 r1, R2 r2) {
return r1.front == r2.front;
}
This doesn't work for ranges that visit the same element twice,
e.g.
On 8/18/14, 1:44 AM, Peter Alexander wrote:
On Monday, 11 August 2014 at 03:29:56 UTC, Andrei Alexandrescu wrote:
[...] can be implemented generically for ranges that offer
front as a reference:
bool sameFront(R1, R2)(R1 r1, R2 r2) {
return r1.front == r2.front;
}
This doesn't work for
On Monday, 11 August 2014 at 15:04:52 UTC, Andrei Alexandrescu
wrote:
http://dpaste.dzfl.pl/a0effbaee0a9
Is your design final with respect to handling degenerate cases?
What do you think about
http://dpaste.dzfl.pl/8fc83cb06de8
?
On 8/17/14, 9:06 AM, Fool wrote:
On Monday, 11 August 2014 at 15:04:52 UTC, Andrei Alexandrescu wrote:
http://dpaste.dzfl.pl/a0effbaee0a9
Is your design final with respect to handling degenerate cases?
What do you think about
http://dpaste.dzfl.pl/8fc83cb06de8
?
Yah, it's a good
Nice work!
Implementation is at http://dpaste.dzfl.pl/a0effbaee0a9. For
historical reasons I've reused an undocumented function
sameHead.
sameHead is documented. I already use it a couple of times.
The algorithm assumes that right is a subrange of whole
sitting at its tail, ...
sameTail
On Monday, 11 August 2014 at 06:56:52 UTC, Dragos Carp wrote:
bool sliceOf(T)(in T[] whole, in T[] slice)
{
return whole.ptr = slice.ptr
whole.ptr + slice.length = whole.ptr + slice.length;
}
Shouldn't the function arguments of sliceOf be reversed to given
a more intuitive UCFS
This reminds me, we still need allBefore to implement
nextPermutation correctly for bidirectional ranges.
https://issues.dlang.org/show_bug.cgi?id=12188
I think this would help here also.
On Monday, 11 August 2014 at 06:56:52 UTC, Dragos Carp wrote:
bool sliceOf(T)(in T[] whole, in T[] slice)
{
return whole.ptr = slice.ptr
whole.ptr + slice.length = whole.ptr + slice.length;
}
Correction: This is what I think you mean:
bool sliceOf(T)(in T[] part,
On Monday, 11 August 2014 at 10:09:53 UTC, Nordlöw wrote:
On Monday, 11 August 2014 at 06:56:52 UTC, Dragos Carp wrote:
bool sliceOf(T)(in T[] whole, in T[] slice)
{
return whole.ptr = slice.ptr
whole.ptr + slice.length = whole.ptr + slice.length;
}
Correction: This is what I think
Correction: This is what I think you mean:
bool sliceOf(T)(in T[] part,
in T[] whole)
{
return (whole.ptr = part.ptr
part.ptr + part.length =
whole.ptr + whole.length);
}
Yes, of course. I had lhs, rhs and messed up the renaming of
those.
On Monday, 11 August 2014 at 11:00:41 UTC, Dragos Carp wrote:
https://github.com/dcarp/phobos/compare/sliceOf
Why not use something like part and whole instead of lhs
and rhs?
It is more self-documenting.
On 8/11/14, 12:29 AM, Andrei Alexandrescu wrote:
Hello,
In which algorithms would one use std::rotate?
On Monday, 11 August 2014 at 13:55:07 UTC, Ary Borenszweig wrote:
On 8/11/14, 12:29 AM, Andrei Alexandrescu wrote:
Hello,
In which algorithms would one use std::rotate?
http://en.wikipedia.org/wiki/Block_sort
On Monday, 11 August 2014 at 13:55:07 UTC, Ary Borenszweig wrote:
On 8/11/14, 12:29 AM, Andrei Alexandrescu wrote:
Hello,
In which algorithms would one use std::rotate?
Pushing N items to the front of a vector is implemented as
pushing N to the back then rotating them to the front.
On 8/11/14, 2:11 AM, Nordlöw wrote:
On Monday, 11 August 2014 at 06:56:52 UTC, Dragos Carp wrote:
bool sliceOf(T)(in T[] whole, in T[] slice)
{
return whole.ptr = slice.ptr
whole.ptr + slice.length = whole.ptr + slice.length;
}
Shouldn't the function arguments of sliceOf be
On 8/11/14, 6:55 AM, Ary Borenszweig wrote:
On 8/11/14, 12:29 AM, Andrei Alexandrescu wrote:
Hello,
In which algorithms would one use std::rotate?
Depends on whom you ask :o). I think it's a fairly obscure algorithm,
better suited as representative of a class rather than frequently
isSliceOf - yum
PR created:
https://github.com/D-Programming-Language/phobos/pull/2416
On Monday, 11 August 2014 at 14:45:09 UTC, Andrei Alexandrescu
wrote:
isSliceOf - yum
Can you elaborate on that?
On Monday, 11 August 2014 at 18:11:19 UTC, Nordlöw wrote:
On Monday, 11 August 2014 at 14:45:09 UTC, Andrei Alexandrescu
wrote:
isSliceOf - yum
Can you elaborate on that?
I get it, Andrei :)
On 8/11/14, 11:12 AM, Nordlöw wrote:
On Monday, 11 August 2014 at 18:11:19 UTC, Nordlöw wrote:
On Monday, 11 August 2014 at 14:45:09 UTC, Andrei Alexandrescu wrote:
isSliceOf - yum
Can you elaborate on that?
I get it, Andrei :)
Yah, all about making a.isSliceOf(b) a nice phrase and keeping
be
done with ranges.
Amid these observations, C++'s std::rotate (http://goo.gl/z8FjV) and
derivative algorithms have been a prime category of examples. C++'s
std::rotate takes a three-legged range, i.e. three iterators begin,
middle, and end, and rotates the range [middle, end) to precede [begin
27 matches
Mail list logo