Thanks, group seems to work fine too.
Andrej M.:
> I want to turn this:
> auto arr = [1, 1, 2, 3, 4, 4];
>
> into this:
> auto arr2 = [[1, 1], [2], [3], [4, 4]];
>
> I want an array of arrays of the same elements. Lazy or not, I don't care.
Currently if you use group like this:
writeln(arr.group());
You get:
[Tuple!(int,uint)(1, 2
Fantastic work, thanks! I'll look into more detail tomorrow, but it
looks good so far. Just added a function helper and made the struct
typed:
import std.array;
import std.range;
struct EquivalentElements(T)
{
T range;
T front_;
this(T range)
{
this.range = range;
this.
On 05/07/2011 09:07 PM, Andrej M. wrote:
I want to turn this:
auto arr = [1, 1, 2, 3, 4, 4];
into this:
auto arr2 = [[1, 1], [2], [3], [4, 4]];
I want an array of arrays of the same elements. Lazy or not, I don't care.
I thought I could get away with this inside some while loop:
auto equals =
I want to turn this:
auto arr = [1, 1, 2, 3, 4, 4];
into this:
auto arr2 = [[1, 1], [2], [3], [4, 4]];
I want an array of arrays of the same elements. Lazy or not, I don't care.
I thought I could get away with this inside some while loop:
auto equals = array(filter!"a == b"(arr));
arr = arr[equa