compact

Compacts a list of values

  1. auto compact(Range range)
  2. auto compact(Values values)
    compact
    (
    alias pred = null
    Values...
    )
    (
    Values values
    )
    if (
    !is(from!"std.traits".CommonType!Values == void)
    )

Parameters

values
Type: Values

list of values that share a common type

Return Value

Type: auto

Compacted array of values cast to common type T

Examples

1 import ddash.utils: isFalsey;
2 auto a = compact!isFalsey(1, 0, 2, 0, 3);
3 auto b = compact!isFalsey(1, 0, 2.0, 0, 3);
4 
5 assert(a.equal([1, 2, 3]));
6 assert(b.equal([1, 2, 3]));
7 
8 static assert(is(typeof(a.array) == int[]));
9 static assert(is(typeof(b.array) == double[]));

Meta

Since

0.0.1