On Thursday, 14 August 2014 at 00:56:47 UTC, Jonathan M Davis wrote:
You forgot the !, making the predicate a function argument. It

Great!

My solution:

auto dropWhile(R, E)(R range, E element) if (isInputRange!R &&
is(ElementType!R == E))
{
    import std.algorithm: find;
    return range.find!(a => a != element);
}

unittest
{
    assert([1, 2, 3].dropWhile(1) == [2, 3]);
    assert([1, 1, 1, 2, 3].dropWhile(1) == [2, 3]);
    assert([1, 2, 3].dropWhile(2) == [1, 2, 3]);
    assert("abc".dropWhile(cast(dchar)'a') == "bc");
}

Reply via email to