## digitalmars.D.announce - Mir Algorithm v0.5.16: safe ndslice; shortcuts; topology.pairwise

• 9il (38/38) May 13 2017 ### Slice is safe now
• 9il (1/1) May 13 2017 https://github.com/libmir/mir-algorithm/releases/tag/v0.5.16
• jmh530 (8/9) May 14 2017 The documentation for mir.functional might need an update based
• 9il (14/24) May 14 2017 1. RefTuple can hold pointers instead of values. For example
9il <ilyayaroshenko gmail.com> writes:
```

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

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

`[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);
```

- `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
9il <ilyayaroshenko gmail.com> writes:
```https://github.com/libmir/mir-algorithm/releases/tag/v0.5.16
```
May 13 2017
jmh530 <john.michael.hall gmail.com> writes:
```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
```
May 14 2017
9il <ilyayaroshenko gmail.com> writes:
```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";