public auto uniquer(R)(R range)

Lazily iterate over range and returning only uniques

Example

import std.array : array;
assertEqual( [1,1,1,1].uniquer.array, [1] );
assertEqual( [1].uniquer.array, [1] );
assertEqual( "".uniquer.array, [] );
assertEqual( [1,2,1,3].uniquer.array, [1,2,3] );
assertEqual( [1,2,1,3,1,2].uniquer.array, [1,2,3] );
assertEqual( [1,2,3].uniquer.array, [1,2,3] );
assertEqual( ["a","b","a","c","a","c"].uniquer.array, ["a","b","c"] );

import std.typecons : tuple;
assertEqual( [tuple(1,"a"),tuple(1,"b"),tuple(2,"b"),tuple(1,"b")]
        .uniquer.array, [tuple(1,"a"),tuple(1,"b"),tuple(2,"b")] );

public auto mergeRange(R1, R2)(
    R1 r1, 
    R2 r2) 
if(isInputRange!R1 || isInputRange!R2)

Merge the elements of two ranges. If first is not a range then merge that with each element of the second range and vice versa.

Example

import std.range : front;
import ggplotd.aes : Aes, DefaultValues;

auto xs = ["a", "b"];
auto ys = ["c", "d"];
auto labels = ["e", "f"];
auto aes = Aes!(string[], "x", string[], "y", string[], "label")(xs, ys, labels);
auto nlAes = mergeRange(DefaultValues, aes );
assertEqual(nlAes.front.x, "a");
assertEqual(nlAes.front.label, "e");
assertEqual(nlAes.front.colour, "black");
auto nlAes2 = aes.mergeRange(DefaultValues);
assertEqual(nlAes2.front.x, "a");
assertEqual(nlAes2.front.label, "");
assertEqual(nlAes2.front.colour, "black");

Some helper functions for ranges

Functions

autouniquer

Lazily iterate over range and returning only uniques

automergeRange

Merge the elements of two ranges. If first is not a range then merge that with each element of the second range and vice versa.