Thread overview
Mir Algorithm v0.5.16: @safe ndslice; shortcuts; topology.pairwise instead of isSorted and isStrictlyMonotonic
May 13, 2017
9il
May 13, 2017
9il
May 14, 2017
jmh530
May 15, 2017
9il
May 13, 2017
### Slice is safe now

User-defined iterators must care about their safety except bounds checks.
Bounds are checked in ndslice code.

### Deprecations

 - `tuple` was renamed to `refTuple`
 - `isSorted` and `isStrictlyMonotonic` are deprecated. Use `pairwise` and `all` instead.

`[float.nan, 1].isSorted` is true both for Mir and Phobos, but it must be false.
`*.pairwise!"a <= b".all` solves this issue explicitly.

```d
import mir.ndslice.algorithm: all;
import mir.ndslice.slice;
import mir.ndslice.sorting: sort;
import mir.ndslice.topology: pairwise;

auto arr = [1, 1, 2].sliced;

assert(arr.pairwise!"a <= b".all);
assert(!arr.pairwise!"a < b".all);

arr = [4, 3, 2, 1].sliced;

assert(!arr.pairwise!"a <= b".all);
assert(!arr.pairwise!"a < b".all);

sort(arr);

assert(arr.pairwise!"a <= b".all);
assert(arr.pairwise!"a < b".all);
```

### New API

- `pairwise` - pairwise map for vectors. It is shortcut for `topology.slide`.
- `Slice.field` - returns underlying array for contiguous ndslices
- Definition shortcuts for Slice
  - `UniversalVector`
  - `ContiguousMatrix`
  - `CanonicalMatrix`
  - `UniversalMatrix`
  - `ContiguousTensor`
  - `CanonicalTensor`
  - `UniversalTensor`

May 13, 2017
https://github.com/libmir/mir-algorithm/releases/tag/v0.5.16
May 14, 2017
On Saturday, 13 May 2017 at 08:10:20 UTC, 9il wrote:
> https://github.com/libmir/mir-algorithm/releases/tag/v0.5.16

The documentation for mir.functional might need an update based on the refTuple change. The links at the top are missing refTuple and RefTuple. tuple doesn't go anywhere, also ref doesn't either.

I didn't really realize these were in there. How does it compare to std.typecons.Tuple? I was thinking about doing some work with std.typecons.Tuple's that hold mir.slices and not sure if I should use RefTuple instead.
May 15, 2017
On Sunday, 14 May 2017 at 17:29:44 UTC, jmh530 wrote:
> On Saturday, 13 May 2017 at 08:10:20 UTC, 9il wrote:
>> https://github.com/libmir/mir-algorithm/releases/tag/v0.5.16
>
> The documentation for mir.functional might need an update based on the refTuple change. The links at the top are missing refTuple and RefTuple. tuple doesn't go anywhere, also ref doesn't either.

Thanks, fixed.

> I didn't really realize these were in there. How does it compare to std.typecons.Tuple? I was thinking about doing some work with std.typecons.Tuple's that hold mir.slices and not sure if I should use RefTuple instead.

1. RefTuple can hold pointers instead of values. For example Mir's zip, cartesian use RefTuples. This makes zip faster and more flexible, because it is partially mutable compared with Tuple.

2. Ndslice composed of RefTuples has special syntax with Map, for example "a + b" instead of "a[0] + a[0]" .

3. RefTuple does not ha ` [0]` syntax or other names then `a`, `b`, `c`.

4. RefTuple is faster to compile, though

Example:

auto s = zip(mask, b, c).map!"a ? b : c";

Loads either a or b.