Horizon
Loading...
Searching...
No Matches
Transformation

Transformation algorithms. More...

Topics

 lazy

Typedefs

template<META_TYPE_CONSTRAINT(list_like) L, typename State, META_TYPE_CONSTRAINT(invocable) Fn>
using meta::fold = _t<detail::fold_<L, id<State>, Fn>>
 Return a new meta::list constructed by doing a left fold of the list L using binary invocable Fn and initial state State.
template<META_TYPE_CONSTRAINT(list_like) L, typename State, META_TYPE_CONSTRAINT(invocable) Fn>
using meta::accumulate = fold<L, State, Fn>
 An alias for meta::fold.
template<META_TYPE_CONSTRAINT(list_like) L, typename State, META_TYPE_CONSTRAINT(invocable) Fn>
using meta::reverse_fold = _t<detail::reverse_fold_<L, State, Fn>>
 Return a new meta::list constructed by doing a right fold of the list L using binary invocable Fn and initial state State.
template<META_TYPE_CONSTRAINT(list_like)... Ls>
using meta::concat_ = _t<detail::concat_<Ls...>>
 Concatenates several lists into a single list.
template<META_TYPE_CONSTRAINT(list_like) ListOfLists>
using meta::join = apply<quote<concat>, ListOfLists>
 Joins a list of lists into a single list.
template<typename... Args>
using meta::transform = _t<detail::transform_<list<Args...>>>
 Return a new meta::list constructed by transforming all the elements in L with the unary invocable Fn.
template<META_TYPE_CONSTRAINT(list_like) L, std::size_t N>
using meta::drop_c = _t<detail::drop_<L, N>>
 Return a new meta::list by removing the first N elements from L.
template<META_TYPE_CONSTRAINT(list_like) L, META_TYPE_CONSTRAINT(integral) N>
using meta::drop = drop_c<L, N::type::value>
 Return a new meta::list by removing the first N elements from L.
template<META_TYPE_CONSTRAINT(list_like) L, typename... Ts>
using meta::push_front = apply<bind_front<quote<list>, Ts...>, L>
 Return a new meta::list by adding the element T to the front of L.
template<META_TYPE_CONSTRAINT(list_like) L>
using meta::pop_front = _t<detail::pop_front_<L>>
 Return a new meta::list by removing the first element from the front of L.
template<META_TYPE_CONSTRAINT(list_like) L, typename... Ts>
using meta::push_back = apply<bind_back<quote<list>, Ts...>, L>
 Return a new meta::list by adding the element T to the back of L.
template<META_TYPE_CONSTRAINT(list_like) L, typename T, typename U>
using meta::replace = _t<detail::replace_<L, T, U>>
 Return a new meta::list where all instances of type T have been replaced with U.
template<META_TYPE_CONSTRAINT(list_like) L, typename C, typename U>
using meta::replace_if = _t<detail::replace_if_<L, C, U>>
 Return a new meta::list where all elements A of the list L for which invoke<C,A>::value is true have been replaced with U.
template<typename L, typename Pred>
using meta::filter = join<transform<L, detail::filter_<Pred>>>
 Returns a new meta::list where only those elements of L that satisfy the Callable Pred such that invoke<Pred,A>::value is true are present.
template<META_TYPE_CONSTRAINT(list_like) ListOfLists>
using meta::transpose
 Given a list of lists of types ListOfLists, transpose the elements from the lists.
template<META_TYPE_CONSTRAINT(invocable) Fn, META_TYPE_CONSTRAINT(list_like) ListOfLists>
using meta::zip_with = transform<transpose<ListOfLists>, uncurry<Fn>>
 Given a list of lists of types ListOfLists and an invocable Fn, construct a new list by calling Fn with the elements from the lists pairwise.
template<META_TYPE_CONSTRAINT(list_like) ListOfLists>
using meta::zip = transpose<ListOfLists>
 Given a list of lists of types ListOfLists, construct a new list by grouping the elements from the lists pairwise into meta::lists.
template<META_TYPE_CONSTRAINT(list_like) L>
using meta::reverse = _t<detail::reverse_<L>>
 Return a new meta::list by reversing the elements in the list L.
template<META_TYPE_CONSTRAINT(list_like) L>
using meta::unique = fold<L, list<>, quote_trait<detail::insert_back_>>
 Return a new meta::list where all duplicate elements have been removed.
template<META_TYPE_CONSTRAINT(list_like) L, META_TYPE_CONSTRAINT(invocable) Fn>
using meta::partition = fold<L, pair<list<>, list<>>, detail::partition_<Fn>>
 Returns a pair of lists, where the elements of L that satisfy the invocable Fn such that invoke<Fn,A>::value is true are present in the first list and the rest are in the second.
template<META_TYPE_CONSTRAINT(list_like) L, META_TYPE_CONSTRAINT(invocable) Fn>
using meta::sort = _t<detail::sort_<L, Fn>>
 Return a new meta::list that is sorted according to invocable predicate Fn.
template<META_TYPE_CONSTRAINT(list_like) ListOfLists>
using meta::cartesian_product
 Given a list of lists ListOfLists, return a new list of lists that is the Cartesian Product.

Detailed Description

Transformation algorithms.

Typedef Documentation

◆ accumulate

template<META_TYPE_CONSTRAINT(list_like) L, typename State, META_TYPE_CONSTRAINT(invocable) Fn>
using meta::accumulate = fold<L, State, Fn>

An alias for meta::fold.

Complexity
O(N).

◆ cartesian_product

template<META_TYPE_CONSTRAINT(list_like) ListOfLists>
using meta::cartesian_product
Initial value:
compose< quote< _t >, quote< C > > quote_trait
Turn a trait template C into an invocable.
Definition meta.hpp:955
_t< detail::reverse_fold_< L, State, Fn > > reverse_fold
Return a new meta::list constructed by doing a right fold of the list L using binary invocable Fn and...
Definition meta.hpp:1661

Given a list of lists ListOfLists, return a new list of lists that is the Cartesian Product.

Like the sequence function from the Haskell Prelude.

Complexity
O(N * M), where N is the size of the outer list, and M is the size of the inner lists.

◆ concat_

template<META_TYPE_CONSTRAINT(list_like)... Ls>
using meta::concat_ = _t<detail::concat_<Ls...>>

Concatenates several lists into a single list.

Precondition
The parameters must all be instantiations of meta::list.
Complexity
O(L) where L is the number of lists in the list of lists.

◆ drop

template<META_TYPE_CONSTRAINT(list_like) L, META_TYPE_CONSTRAINT(integral) N>
using meta::drop = drop_c<L, N::type::value>

Return a new meta::list by removing the first N elements from L.

Complexity
O(1).

◆ drop_c

template<META_TYPE_CONSTRAINT(list_like) L, std::size_t N>
using meta::drop_c = _t<detail::drop_<L, N>>

Return a new meta::list by removing the first N elements from L.

Complexity
O(1).

◆ filter

template<typename L, typename Pred>
using meta::filter = join<transform<L, detail::filter_<Pred>>>

Returns a new meta::list where only those elements of L that satisfy the Callable Pred such that invoke<Pred,A>::value is true are present.

That is, those elements that don't satisfy the Pred are "removed".

Complexity
O(N).

◆ fold

template<META_TYPE_CONSTRAINT(list_like) L, typename State, META_TYPE_CONSTRAINT(invocable) Fn>
using meta::fold = _t<detail::fold_<L, id<State>, Fn>>

Return a new meta::list constructed by doing a left fold of the list L using binary invocable Fn and initial state State.

That is, the State(N) for the list element A(N) is computed by Fn(State(N-1), A(N)) -> State(N).

Complexity
O(N).

◆ join

template<META_TYPE_CONSTRAINT(list_like) ListOfLists>
using meta::join = apply<quote<concat>, ListOfLists>

Joins a list of lists into a single list.

Precondition
The parameter must be an instantiation of meta::list<T...> where each T is itself an instantiation of meta::list.
Complexity
O(L) where L is the number of lists in the list of lists.

◆ partition

template<META_TYPE_CONSTRAINT(list_like) L, META_TYPE_CONSTRAINT(invocable) Fn>
using meta::partition = fold<L, pair<list<>, list<>>, detail::partition_<Fn>>

Returns a pair of lists, where the elements of L that satisfy the invocable Fn such that invoke<Fn,A>::value is true are present in the first list and the rest are in the second.

Complexity
O(N).

◆ pop_front

template<META_TYPE_CONSTRAINT(list_like) L>
using meta::pop_front = _t<detail::pop_front_<L>>

Return a new meta::list by removing the first element from the front of L.

Complexity
O(1).

◆ push_back

template<META_TYPE_CONSTRAINT(list_like) L, typename... Ts>
using meta::push_back = apply<bind_back<quote<list>, Ts...>, L>

Return a new meta::list by adding the element T to the back of L.

Complexity
O(1).
Note
pop_back not provided because it cannot be made to meet the complexity guarantees one would expect.

◆ push_front

template<META_TYPE_CONSTRAINT(list_like) L, typename... Ts>
using meta::push_front = apply<bind_front<quote<list>, Ts...>, L>

Return a new meta::list by adding the element T to the front of L.

Complexity
O(1).

◆ replace

template<META_TYPE_CONSTRAINT(list_like) L, typename T, typename U>
using meta::replace = _t<detail::replace_<L, T, U>>

Return a new meta::list where all instances of type T have been replaced with U.

Complexity
O(N).

◆ replace_if

template<META_TYPE_CONSTRAINT(list_like) L, typename C, typename U>
using meta::replace_if = _t<detail::replace_if_<L, C, U>>

Return a new meta::list where all elements A of the list L for which invoke<C,A>::value is true have been replaced with U.

Complexity
O(N).

◆ reverse

template<META_TYPE_CONSTRAINT(list_like) L>
using meta::reverse = _t<detail::reverse_<L>>

Return a new meta::list by reversing the elements in the list L.

Complexity
O(N).

◆ reverse_fold

template<META_TYPE_CONSTRAINT(list_like) L, typename State, META_TYPE_CONSTRAINT(invocable) Fn>
using meta::reverse_fold = _t<detail::reverse_fold_<L, State, Fn>>

Return a new meta::list constructed by doing a right fold of the list L using binary invocable Fn and initial state State.

That is, the State(N) for the list element A(N) is computed by Fn(A(N), State(N+1)) -> State(N).

Complexity
O(N).

◆ sort

template<META_TYPE_CONSTRAINT(list_like) L, META_TYPE_CONSTRAINT(invocable) Fn>
using meta::sort = _t<detail::sort_<L, Fn>>

Return a new meta::list that is sorted according to invocable predicate Fn.

Complexity
Expected: O(N log N) Worst case: O(N^2).
static_assert(std::is_same_v<L1, list<char[1], char[2], char[3], char[5], char[5], char[6], char[10]>>, "");
defer< sizeof_, T > sizeof_
Definition meta.hpp:838
_t< detail::sort_< L, Fn > > sort
Return a new meta::list that is sorted according to invocable predicate Fn.
Definition meta.hpp:3277
A list of types.
Definition meta.hpp:1684

◆ transform

template<typename... Args>
using meta::transform = _t<detail::transform_<list<Args...>>>

Return a new meta::list constructed by transforming all the elements in L with the unary invocable Fn.

transform can also be called with two lists of the same length and a binary invocable, in which case it returns a new list constructed with the results of calling Fn with each element in the lists, pairwise.

Complexity
O(N).

◆ transpose

template<META_TYPE_CONSTRAINT(list_like) ListOfLists>
using meta::transpose
Initial value:
_t< detail::fold_< L, id< State >, Fn > > fold
Return a new meta::list constructed by doing a left fold of the list L using binary invocable Fn and ...
Definition meta.hpp:1589
An invocable that partially applies the invocable Fn by binding the arguments Us to the back of Fn.
Definition meta.hpp:979
Turn a template C into an invocable.
Definition meta.hpp:913

Given a list of lists of types ListOfLists, transpose the elements from the lists.

Complexity
O(N * M), where N is the size of the outer list, and M is the size of the inner lists.

◆ unique

template<META_TYPE_CONSTRAINT(list_like) L>
using meta::unique = fold<L, list<>, quote_trait<detail::insert_back_>>

Return a new meta::list where all duplicate elements have been removed.

Complexity
O(N^2).

◆ zip

template<META_TYPE_CONSTRAINT(list_like) ListOfLists>
using meta::zip = transpose<ListOfLists>

Given a list of lists of types ListOfLists, construct a new list by grouping the elements from the lists pairwise into meta::lists.

Complexity
O(N * M), where N is the size of the outer list, and M is the size of the inner lists.

◆ zip_with

template<META_TYPE_CONSTRAINT(invocable) Fn, META_TYPE_CONSTRAINT(list_like) ListOfLists>
using meta::zip_with = transform<transpose<ListOfLists>, uncurry<Fn>>

Given a list of lists of types ListOfLists and an invocable Fn, construct a new list by calling Fn with the elements from the lists pairwise.

Complexity
O(N * M), where N is the size of the outer list, and M is the size of the inner lists.