# ddash 0.0.4

Utility library for D

To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

### ddash

Full API docs available here

A utility library that was inspired by the a javascript library called lodash. The algorithms operate on sequences that are either:

• value sequences:
``````assert(1.concat(2, 3, 4).array == [1, 2, 3, 4]);
``````
• ranges:
``````assert(1.concat([2, 3, 4]).array == [1, 2, 3, 4]);
``````
• a mixture of the above two:
``````assert(1.concat([2, 3], 4).array == [1, 2, 3, 4]);
``````
• associative arrays:
``````auto aa = ["a": 1, "b": 0, "c": 2];
assert(aa.compactValues!(a => a == 0) == ["a": 1, "c": 2]);
``````

Furthermore, a number of algorithms allow you to:

• operate on members of types:

This would be akin to passing in a predicate that extracts a member variable from a type to operate on instead of operating on the whole type. These algorithms usually have a `By` prefix:

class C {

``````int x;
``````

} auto arr1 = [new C(2), new C(3)]; auto arr2 = [new C(2), new C(3)]; assert(arr1.equalBy!"x"(arr2));

• operate via unary or binary predicates:

``````import std.math: ceil;
assert([2.1, 2.4, 1.2, 2.9].difference!ceil([2.3, 0.1]).equal([1.2]));
assert([2.1, 2.4, 1.2, 2.9].difference!((a, b) => ceil(a) < ceil(b))([2.3, 3.4]).equal([1.2]));
``````
• or both:

``````struct A {
int x;
}
auto arr = [A(4), A(8), A(12)];
assert(arr.pullBy!("x", a => a / 2)(5, 9).array == [A(12)]);
``````

#### Features:

• Algorithms that are possibly non-trivial to figure out from D's stadard library Phobos
• Algorithms that are not in D's standard library
• Ability to execute the algorithms on sequences other than ranges
• Integration with Optional!T
• Common utility functions
• Functional programming utilities

#### Subpackages:

• algorithm: contains algorithms that operate mostly on sequences
• ranges: contains navigational algorithms over ranges (moving/jumpting/iterating/etc)
• functional: contains utilties for functional programming
• lang: contains techniques that fill in required language bits (or just stuff I didn't know where to put)
• utils: contains utility types and functions

#### Benchmarks

There's a benchmark dub configuration that can be used to run algorithms and check their speeds. The idea behind this is supposed to be to help with regressions once I figure out how to generate reports.

• Registered by ali akhtarzada
• 0.0.4 released 3 months ago
• aliak00/ddash
• MIT
Authors:
• Ali Akhtarzada
Sub packages:
ddash:algorithm, ddash:functional, ddash:utils, ddash:lang, ddash:range, ddash:common
Dependencies:
ddash:range, ddash:utils, ddash:algorithm, ddash:functional, ddash:lang
Versions:
 0.11.1 2019-Feb-12 0.11.0 2019-Feb-03 0.10.1 2019-Jan-29 0.10.0 2019-Jan-25 0.9.2 2019-Jan-14
Download Stats:
• 1 downloads today

• 4 downloads this week

• 14 downloads this month

• 94 downloads total

Score:
0.3
Short URL:
ddash.dub.pm