mir.functional

Functions that manipulate other functions. This module provides functions for compile time function composition. These functions are helpful when constructing predicates for the algorithms in mir.ndslice.

Functions

Function NameDescription
naryFunCreate a unary, binary or N-nary function from a string. Most often used when defining algorithms on ranges and slices.
pipeJoin a couple of functions into one that executes the original functions one after the other, using one function's result for the next function's argument.
notCreates a function that negates another.
reverseArgsPredicate that reverses the order of its arguments.
forwardForwards function arguments with saving ref-ness.
refTupleRemoves Ref shell.
unrefCreates a RefTuple structure.
__refCreates a Ref structure.

Public Imports

core.lifetime
public import core.lifetime : forward;

Members

Aliases

Unref
alias Unref(V : Ref!T, T) = T
alias Unref(V) = V

Removes Ref shell.

Functions

_ref
Ref!T _ref(T value)

Creates Ref wrapper.

refTuple
RefTuple!Args refTuple(Args args)
staticArray
T[N] staticArray(T[N] a)

Constructs static array.

unref
T unref(V value)
Unref!(RefTuple!T) unref(V value)
V unref(V value)

Removes Ref shell.

Structs

AliasCall
struct AliasCall(T, string methodName, TemplateArgs...)
Undocumented in source.
Ref
struct Ref(T)

Simple wrapper that holds a pointer. It is used for as workaround to return multiple auto ref values.

RefTuple
struct RefTuple(T...)

Simplified tuple structure. Some fields may be type of Ref. Ref stores a pointer to a values.

Templates

Unref
template Unref(V : RefTuple!T, T...)

Removes Ref shell.

adjoin
template adjoin(fun...)

Takes multiple functions and adjoins them together. The result is a RefTuple with one element per passed-in function. Upon invocation, the returned tuple is the adjoined results of all functions. Note: In the special case where only a single function is provided (F.length == 1), adjoin simply aliases to the single passed function (F[0]).

aliasCall
template aliasCall(string methodName, TemplateArgs...)

Replaces call operator (opCall) for the value using its method. The funciton is designed to use with $(NDSLICE, topology, vmap) or $(NDSLICE, topology, map).

naryFun
template naryFun(functions...)

Aliases itself to a set of functions.

not
template not(alias pred)

Negates predicate pred.

pipe
template pipe(fun...)

Composes passed-in functions fun[0], fun[1], ... returning a function f(x) that in turn returns ...(fun[1](fun[0](x))).... Each function can be a regular functions, a delegate, a lambda, or a string.

recurseTemplatePipe
template recurseTemplatePipe(alias Template, size_t N, Args...)
reverseArgs
template reverseArgs(alias fun)

N-ary predicate that reverses the order of arguments, e.g., given pred(a, b, c), returns pred(c, b, a).

selfAndRecurseTemplatePipe
template selfAndRecurseTemplatePipe(alias Template, size_t N, Args...)
selfTemplatePipe
template selfTemplatePipe(alias Template, size_t N, Args...)

Meta

License

Apache-2.0