List

◆ accumulate

template<typename lbd , typename state , typename... seqs>
using metal::accumulate = typedef detail::call< if_<same<size<seqs>...>, detail::_accumulate<lbd> >::template type, state, seqs...>

#include <metal/list/accumulate.hpp>

Description

Computes the recursive invocation of a binary Lambda with the result of the previous invocation and each element of one or more Lists traversed in parallel from the beginning to the end.

Usage

For any Lambda lbd, Value val and Lists l_0, ..., l_n-1

using result = metal::accumulate<lbd, val, l_0, ..., l_n-1>;
Precondition
: metal::size<l_0>{} == metal::size<>{}... == metal::size<l_n-1>{}
Returns
: Value
Semantics:
Equivalent to
using result =
lbd(... lbd(lbd(val, l[0]...), l[1]...), ..., l[m-1]...)
where l[N]... stands for l_0[N], ...[N], l_n-1[N] and lbd(x, y) stands for metal::invoke<lbd, x, y>.

Example

template<typename val, typename num>
using add_extent = val[num::value];
IS_SAME(metal::accumulate<metal::lambda<add_extent>, char, ext>, char[2][5][3]);
IS_SAME(
int, char, float,
int&, char&, float&,
int*, char*, float*,
int[], char[], float[]
>
);

See Also

See also
list, transform, fold_left

◆ all_of

template<typename seq , typename lbd >
using metal::all_of = typedef metal::apply<metal::lambda<metal::and_>, metal::transform<lbd, seq> >

#include <metal/list/all_of.hpp>

Description

Checks whether a predicate holds for all elements of a List .

Usage

For any List l and Lambda lbd

using result = metal::all_of<l, lbd>;
Precondition
: For any element l[i] contained in l, metal::invoke<lbd, l[i]> returns a Number
Returns
: Number
Semantics:
If metal::invoke<lbd, l[i]>{} != false for all l[i] contained in l, then
using result = metal::true_;
otherwise
using result = metal::false_;

Example

See Also

See also
list, any_of, none_of

◆ any_of

template<typename seq , typename lbd >
using metal::any_of = typedef metal::apply<metal::lambda<metal::or_>, metal::transform<lbd, seq> >

#include <metal/list/any_of.hpp>

Description

Checks whether a predicate holds for at least some element of a List .

Usage

For any List l and Lambda lbd

using result = metal::any_of<l, lbd>;
Precondition
: For any element l[i] contained in l, metal::invoke<lbd, l[i]> returns a Number
Returns
: Number
Semantics:
If metal::invoke<lbd, l[i]>{} != false for at least some l[i] contained in l, then
using result = metal::true_;
otherwise
using result = metal::false_;

Example

See Also

See also
list, all_of, none_of

◆ append

template<typename seq , typename... vals>
using metal::append = typedef metal::join<seq, metal::list<vals...> >

#include <metal/list/append.hpp>

Description

Inserts Values at the end of a List .

Usage

For any List l and Values val_0, ..., val_n-1

using result = metal::append<l, val_0, ..., val_n-1>;
Returns
: List
Semantics:
If l contains elements l[0], ..., l[m-1], then
using result = metal::list<
l[0], ..., l[m-1], val_0, ..., val_n-1
>;

Example

IS_SAME(
metal::append<l, char, char[]>,
metal::list<short, int, long, float, double, void, char, char[]>
);

See Also

See also
list, insert, prepend

◆ as_list

template<typename val >
using metal::as_list = typedef typename detail::_as_list<val>::type

#include <metal/list/list.hpp>

Description

Given any Value that is a specialization of a template class or union whose template parameters are all themselves Values, constructs a List that contains all those Values.

Usage

For any Value val

using result = metal::as_list<val>;
Returns
: List

Example

IS_SAME(metal::as_list<std::shared_ptr<int>>, metal::list<int>);
IS_SAME(
metal::as_list<std::unique_ptr<int>>,
metal::list<int, std::default_delete<int>>
);
IS_SAME(
metal::as_list<std::tuple<int, char, float>>,
);

See Also

See also
list, as_lambda

◆ at

template<typename seq , typename num >
using metal::at = typedef detail::call<detail::_at<seq>::template type, num>

#include <metal/list/at.hpp>

Description

Retrieves an element of a List at an arbitrary position.

Usage

For any List l and Number num

using result = metal::at<l, num>;
Precondition
: metal::number<0>{} ≤ num{} < metal::size<l>{}
Returns
: Value
Semantics:
If l contains elements l[0], ..., l[i], ..., l[m-1] and num{} == i, then
using result = l[i];

Example

IS_SAME(metal::at<l, metal::number<0>>, short);
IS_SAME(metal::at<l, metal::number<1>>, int);
IS_SAME(metal::at<l, metal::number<2>>, long);
IS_SAME(metal::at<l, metal::number<3>>, float);
IS_SAME(metal::at<l, metal::number<4>>, double);
IS_SAME(metal::at<l, metal::number<5>>, void);

See Also

See also
list, front, back

◆ back

template<typename seq >
using metal::back = typedef metal::at<seq, metal::dec<metal::size<seq> >>

#include <metal/list/back.hpp>

Description

Retrieves the last element of a List .

Usage

For any List l

using result = metal::back<l>;
Returns
: Value
Semantics:
If l contains elements l[0], ..., l[m-1], then
using result = l[m-1];

Example

See Also

See also
list, at, front

◆ cartesian

template<typename... seqs>
using metal::cartesian = typedef fold_left<lambda<detail::product>, list<list<> >, seqs...>

#include <metal/list/cartesian.hpp>

Description

Computes the cartesian product of Lists.

Usage

For any Lists l_0, ..., l_n-1

using result = metal::cartesian<l_0, ..., l_n-1>;
Returns
: List
Semantics:
Equivalent to
using result = metal::list<
metal::list<l_0[x_0], ...[...], l_n-1[x_n-1]>,
>;
where each x in x_0, ..., x_n-1 varies independently from 0 to n-1.

Example

See Also

See also
list, transpose

◆ cascade

template<typename seq , typename... lbds>
using metal::cascade = typedef apply<fold_right<lambda<detail::cascader>, lbds...>, seq>

#include <metal/list/cascade.hpp>

Description

Recursively applies Lambdas to nested Lists of Lists.

Usage

For any List l and Lambdas lbd_0, ..., lbd_n-1, where n > 0,

using result = metal::cascade<l, lbd_0, ..., lbd_n-1>;
Returns
: Value
Semantics:
If n == 1, then
using result = metal::apply<lbd_0, l>;
otherwise, if l contains elements l[0], ..., l[m-1], then
using result = metal::invoke<
lbd_0,
metal::cascade<l[0], lbd_1, ..., lbd_n-1>>,
metal::cascade<l[1], lbd_1, ..., lbd_n-1>>,
...,
metal::cascade<l[m-1], lbd_1, ..., lbd_n-1>>
>;

Example

struct a; struct b; struct c; struct d;
template<typename...> struct f {};
template<typename...> struct g {};
template<typename...> struct h {};
using tree = metal::list<
>;
IS_SAME(
f<g<h<a>, h<b>>, g<h<c>, h<d>>>
);

See Also

See also
list, cartesian

◆ combine

template<typename seq , typename num = metal::size<seq>>
using metal::combine = typedef metal::apply< metal::lambda<metal::cartesian>, metal::repeat<metal::if_<metal::is_list<seq>, seq>, num> >

#include <metal/list/combine.hpp>

Description

Computes all possible combinations (with repetition) from the elements in a List .

Usage

For any List l and Number num

using result = metal::combine<l, num>;
Returns
: List
Semantics:
If l contains elements l[0], ..., l[m-1] and num holds the constant n, then
using result = metal::list<
metal::list<l[x_0], ...[...], l[x_n-1]>,
>;
where each x in x_0, ..., x_n-1 varies independently from 0 to m-1.

Example

See Also

See also
list, powerset, cartesian, cascade

◆ contains

template<typename seq , typename val >
using metal::contains = typedef metal::any_of<seq, metal::partial<metal::lambda<metal::same>, val> >

#include <metal/list/contains.hpp>

Description

Checks whether a Value is contained in a List .

Usage

For any List l and Value val

using result = metal::contains<l, val>;
Returns
: Number
Semantics:
If val is contained in l, then
using result = metal::true_;
otherwise
using result = metal::false_;

Example

See Also

See also
list, count, find

◆ copy

template<typename seq , typename val >
using metal::copy = typedef metal::copy_if<seq, metal::partial<metal::lambda<metal::same>, val> >

#include <metal/list/copy.hpp>

Description

Removes all elements from a List except for those that are the same as some Value .

Usage

For any List l and Value val

using result = metal::copy<l, val>;
Returns
: List
Semantics:
Equivalent to
using result = metal::list<...>;
where result contains all and only the occurrences of val in l.

Example

See Also

See also
list, copy_if, remove, replace

◆ copy_if

template<typename seq , typename lbd >
using metal::copy_if = typedef metal::remove_if<seq, metal::bind<metal::lambda<metal::not_>, lbd> >

#include <metal/list/copy_if.hpp>

Description

Removes all elements from a List except for those that satisfy a predicate.

Usage

For any List l and Lambda lbd

using result = metal::copy_if<l, lbd>;
Precondition
: For any element l[i] contained in l, metal::invoke<lbd, l[i]> returns a Number
Returns
: List
Semantics:
Equivalent to
using result = metal::list<...>;
where result contains all and only the elements l[i] in l for which metal::invoke<lbd, l[i]>{} != false.

Example

See Also

See also
list, copy, remove_if, replace_if

◆ count

template<typename seq , typename val >
using metal::count = typedef metal::count_if<seq, metal::partial<metal::lambda<metal::same>, val> >

#include <metal/list/count.hpp>

Description

Counts the occurrences of a Value in a List .

Usage

For any List l and Value val

using result = metal::count<l, val>;
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<n>;
where n is the number of occurrences of val in l.

Example

See Also

See also
list, count_if, contains, find

◆ count_if

template<typename seq , typename lbd >
using metal::count_if = typedef metal::apply<metal::lambda<metal::add>, metal::transform<lbd, seq> >

#include <metal/list/count_if.hpp>

Description

Counts the elements in a List that satisfy a predicate.

Usage

For any List l and Lambda lbd

using result = metal::count_if<l, lbd>;
Precondition
: For any element l[i] contained in l, metal::invoke<lbd, l[i]> returns a Number
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<n>;
where n is the number of occurrences of some l[i] in l, such that metal::invoke<lbd, l[i]>{} != false.

Example

See Also

See also
list, count, all, any, none, find_if

◆ drop

template<typename seq , typename n >
using metal::drop = typedef metal::range<seq, n, metal::size<seq> >

#include <metal/list/drop.hpp>

Description

Removes all elements from the beginning up to an arbitrary index of a List .

Usage

For any List l and Number num

using result = metal::drop<l, num>;
Precondition
: metal::number<0>{} ≤ num{} ≤ metal::size<l>{}
Returns
: List
Semantics:
If l contains elements l[0], ..., l[i], ..., l[m-1] and num{} == i, then
using result = metal::list<l[i], ..., l[m-1]>;

Example

See Also

See also
list, range, erase, take

◆ empty

template<typename seq >
using metal::empty = typedef metal::not_<metal::size<seq> >

#include <metal/list/empty.hpp>

Description

Checks whether a List has no elements.

Usage

For any List l

using result = metal::empty<l>;
Returns
: Number
Semantics:
If l contains at least one element, then
using result = metal::false_;
otherwise
using result = metal::true_;

Example

See Also

See also
list, size

◆ erase

template<typename seq , typename beg , typename end = inc<beg>>
using metal::erase = typedef metal::join< metal::take<seq, metal::min<beg, end> >, metal::drop<seq, metal::max<beg, end> >>

#include <metal/list/erase.hpp>

Description

Removes all elements between two arbitrary indices of a List .

Usage

For any List l and Numbers beg and end

Precondition
: metal::number<0>{} ≤ beg{} ≤ metal::size<l>{} and metal::number<0>{} ≤ end{} ≤ metal::size<l>{}
Returns
: List
Semantics:
If l contains elements l[0], ..., l[i], ..., l[j], ..., l[m-1] and either beg{} == i and end{} == j or beg{} == j and end{} == i, then
using result = metal::list<
l[0], ..., l[i-1], l[j], ..., l[m-1]
>;

Example

See Also

See also
list, range, take, drop

◆ find

template<typename seq , typename val >
using metal::find = typedef metal::find_if<seq, metal::partial<metal::lambda<metal::same>, val> >

#include <metal/list/find.hpp>

Description

Returns the index of the first occurrence of a Value in a List .

Usage

For any List l and Value val

using result = metal::find<l, val>;
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<i>;
where i is index of the first occurrence of val in l, otherwise
using result = metal::size<l>;

Example

See Also

See also
list, find_if, count, contains

◆ find_if

template<typename seq , typename lbd >
using metal::find_if = typedef typename detail::_find_if<transform<lbd, seq> >::type

#include <metal/list/find_if.hpp>

Description

Returns the index of the first element of a List that satisfy a predicate.

Usage

For any List l and Lambda lbd

using result = metal::find_if<l, lbd>;
Precondition
: For any element l[i] contained in l, metal::invoke<lbd, l[i]> returns a Number
Returns
: Number
Semantics:
Equivalent to
using result = metal::number<i>;
where i is such that l[i] is the first element in l for which metal::invoke<lbd, l[i]>{} != false, otherwise
using result = metal::size<l>;

Example

See Also

See also
list, find, all, any, none, count_if

◆ flatten

template<typename seq >
using metal::flatten = typedef metal::apply<metal::lambda<metal::join>, seq>

#include <metal/list/flatten.hpp>

Description

Collapses a List of Lists into a flat List that contains all the elements of the inner Lists preserving their order.

Usage

For any List l

using result = metal::flatten<l>;
Returns
: List
Semantics:
If l contains elements l[0], ..., l[m-1], then
using result = metal::list<l[0][:], ...[:], l[n-1][:]>;
where l[:] stands for the expansion of all elements contained in l.

Example

IS_SAME(
char, wchar_t, char16_t, char32_t,
short, int, long, long long,
float, double, long double
>
);

See Also

See also
list, join

◆ front

template<typename seq >
using metal::front = typedef metal::at<seq, metal::number<0> >

#include <metal/list/front.hpp>

Description

Retrieves the first element of a List .

Usage

For any List l

using result = metal::front<l>;
Returns
: Value
Semantics:
If l contains elements l[0], ..., l[m-1], then
using result = l[0];

Example

See Also

See also
list, at, back

◆ indices

template<typename seq >
using metal::indices = typedef metal::iota<metal::number<0>, metal::size<seq> >

#include <metal/list/indices.hpp>

Description

Replaces each element of a List by its corresponding index.

Usage

For any List l

using result = metal::indices<l>;
Returns
: List
Semantics:
If l contains elements l[0], ..., l[m-1], then

Example

See Also

See also
list, iota

◆ insert

template<typename seq , typename num , typename... vals>
using metal::insert = typedef metal::splice<seq, num, metal::list<vals...> >

#include <metal/list/insert.hpp>

Description

Inserts a Value in a List at an arbitrary position.

Usage

For any List l, Number num and Values val_0, ..., val_n-1

using result = metal::insert<l, num, val_0, ..., val_n-1>;
Precondition
: metal::number<0>{} ≤ num{} ≤ metal::size<l>{}
Returns
: List
Semantics:
If l contains elements l[0], ..., l[i], ..., l[m-1] and num{} == i, then
using result = metal::list<
l[0], ..., val_0, ..., val_n-1, l[i], ..., l[m-1]
>;

Example

See Also

See also
list, prepend, append, splice

◆ iota

template<typename start , typename size , typename stride = number<1>>
using metal::iota = typedef typename detail::_iota<start, size, stride>::type

#include <metal/list/iota.hpp>

Description

Generates a sequence of Numbers.

Usage

For any Numbers st, sz and sd

using result = metal::iota<st, sz, sd>;
Returns
: List
Semantics:
If sz is positive, then
using result = metal::numbers<
st{}, st{} + sd{}, ..., st{} + (sz{} - 1)*sd{}
>;
otherwise, if sz is negative, then
using result = metal::numbers<
st{}, st{} - sd{}, ..., st{} - (1 - sz{})*sd{}
>;
otherwise
using result = metal::numbers<>;

Example

See Also

See also
list, repeat, numbers

◆ is_list

template<typename val >
using metal::is_list = typedef typename detail::_is_list<val>::type

#include <metal/list/list.hpp>

Description

Checks whether some Value is a List .

Usage

For any Value val

using result = metal::is_list<val>;
Returns
: Number
Semantics:
If val is a List , then
using result = metal::true_;
otherwise
using result = metal::false_;

Example

See Also

See also
list, is_value, is_number, is_lambda, is_pair, is_map

◆ join

template<typename... seqs>
using metal::join = typedef detail::call<detail::joiner<sizeof...(seqs)>::template type, seqs...>

#include <metal/list/join.hpp>

Description

Concatenates Lists.

Usage

For any Lists l_0, ..., l_n-1

using result = metal::join<l_0, ..., l_n-1>;
Returns
: List
Semantics:
Equivalent to
using result = metal::list<l_0[:], ...[:], l_n-1[:]>;
where l[:] stands for the expansion of all elements contained in l.

Example

IS_SAME(
char, wchar_t, char16_t, char32_t,
short, int, long, long long,
float, double, long double
>
);

See Also

See also
list, flatten

◆ list

template<typename... vals>
using metal::list = typedef struct { }

#include <metal/list/list.hpp>

Description

Constructs a List out of a sequence of Values.

Usage

For any Values val_0, ..., val_n-1

using result = metal::list<val_0, ..., val_n-1>;
Returns
: List

See Also

See also
is_list

◆ none_of

template<typename seq , typename lbd >
using metal::none_of = typedef metal::not_<metal::any_of<seq, lbd> >

#include <metal/list/none_of.hpp>

Description

Checks whether a predicate does not hold for any element of a List .

Usage

For any List l and Lambda lbd

using result = metal::none_of<l, lbd>;
Precondition
: For any element l[i] contained in l, metal::invoke<lbd, l[i]> returns a Number
Returns
: Number
Semantics:
If metal::invoke<lbd, l[i]>{} == false for all l[i] contained in l, then
using result = metal::true_;
otherwise
using result = metal::false_;

Example

See Also

See also
list, all_of, any_of

◆ partition

template<typename seq , typename lbd >
using metal::partition = typedef metal::pair<metal::copy_if<seq, lbd>, metal::remove_if<seq, lbd> >

#include <metal/list/partition.hpp>

Description

Splits a List in two according to a predicate.

Usage

For any List l and Lambda lbd

using result = metal::partition<l, lbd>;
Precondition
: For any element l[i] contained in l, metal::invoke<lbd, l[i]> returns a Number
Returns
: Pair
Semantics:
Equivalent to
using result = metal::pair<l_1, l_2>;
where l_1 contains all and only the elements l[i] in l for which metal::invoke<lbd, l[i]>{} != false and l_2 contains the remaining elements.

Example

See Also

See also
list, copy_if, remove_if

◆ powerset

template<typename seq >
using metal::powerset = typedef accumulate<lambda<detail::power>, list<list<> >, metal::reverse<seq> >

#include <metal/list/powerset.hpp>

Description

Computes the powerset of a List .

Usage

For any List l

using result = metal::powerset<l>;
Returns
: List
Semantics:
If l contains elements l[0], ..., l[m-1], then where the notation l[2^m] stands for the expansion of all elements in l, whose indices correspond to 1-bits of the number 2^m written in binary base and metal::list<l[2^m]>... stands for the expansion for all numbers in 0...2^m.

Example

See Also

See also
list, combine, cartesian, cascade

◆ prepend

template<typename seq , typename... vals>
using metal::prepend = typedef metal::join<metal::list<vals...>, seq>

#include <metal/list/prepend.hpp>

Description

Inserts Values at the beginning of a List .

Usage

For any List l and Values val_0, ..., val_n-1

using result = metal::prepend<l, val_0, ..., val_n-1>;
Returns
: List
Semantics:
If l contains elements l[0], ..., l[m-1], then
using result = metal::list<
val_0, ..., val_n-1, l[0], ..., l[m-1]
>;

Example

IS_SAME(
metal::prepend<l, char, char[]>,
metal::list<char, char[], short, int, long, float, double, void>
);

See Also

See also
list, insert, append

◆ range

template<typename seq , typename beg , typename end >
using metal::range = typedef detail::range< seq, if_<not_<or_<greater<number<0>, beg>, greater<beg, size<seq> >> >, beg>, if_<not_<or_<greater<number<0>, end>, greater<end, size<seq> >> >, end> >

#include <metal/list/range.hpp>

Description

Returns a contiguous subsequence of a List .

Usage

For any List l and Numbers beg and end

Precondition
: metal::number<0>{} ≤ beg{} ≤ metal::size<l>{} and metal::number<0>{} ≤ end{} ≤ metal::size<l>{}
Returns
: List
Semantics:
If l contains elements l[0], ..., l[i], ..., l[j], ..., l[m-1], beg{} == i and end{} == j, then
using result = metal::list<l[i], ..., l[j-1]>;
otherwise, if beg{} == j and end{} == i, then
using result = metal::list<l[j-1], ..., l[i]>;

Example

See Also

See also
list, erase, take, drop

◆ remove

template<typename seq , typename val >
using metal::remove = typedef metal::remove_if<seq, metal::partial<metal::lambda<metal::same>, val> >

#include <metal/list/remove.hpp>

Description

Removes all elements from a List that are the same as some Value .

Usage

For any List l and Value val

using result = metal::remove<l, val>;
Returns
: List
Semantics:
Equivalent to
using result = metal::list<...>;
where result contains all and only the elements in l which are distinct from val.

Example

See Also

See also
list, remove_if, copy, replace

◆ remove_if

template<typename seq , typename lbd >
using metal::remove_if = typedef metal::replace_if<seq, lbd>

#include <metal/list/remove_if.hpp>

Description

Removes all elements from a List that satisfy a predicate.

Usage

For any List l and Lambda lbd

using result = metal::remove_if<l, lbd>;
Precondition
: For any element l[i] contained in l, metal::invoke<lbd, l[i]> returns a Number
Returns
: List
Semantics:
Equivalent to
using result = metal::list<...>;
where result contains all and only the elements l[i] in l for which metal::invoke<lbd, l[i]>{} == false.

Example

See Also

See also
list, remove, copy_if, replace_if

◆ repeat

template<typename val , typename num >
using metal::repeat = typedef metal::transform< metal::always<val>, metal::iota<metal::number<0>, num, metal::number<0> >>

#include <metal/list/repeat.hpp>

Description

Returns a List that contains a Number of copies of the same Value .

Usage

For any Value val and Number num

using result = metal::repeat<val, num>;
Returns
: List
Semantics:
If num holds the constant n, then
using result = metal::list<val_0, ..., val_n-1>;
where val_0, ..., val_n-1 are all identical to val.

Example

See Also

See also
list, iota

◆ replace

template<typename seq , typename val , typename... vals>
using metal::replace = typedef metal::replace_if< seq, metal::partial<metal::lambda<metal::same>, val>, vals...>

#include <metal/list/replace.hpp>

Description

Replaces every occurrence of a Value in a List by another Value .

Usage

For any List l and Values val and val_0, ..., val_n-1

using result = metal::replace<l, val, val_0, ..., val_n-1>;
Returns
: List
Semantics:
Equivalent to
using result = metal::list<...>;
where result contains all and only the elements in l, except that every occurrence of val has been replaced by val_0, ..., val_n-1.

Example

See Also

See also
list, replace_if, copy, remove

◆ replace_if

template<typename seq , typename lbd , typename... vals>
using metal::replace_if = typedef typename detail::_replace_if<seq, transform<lbd, seq>, vals...>::type

#include <metal/list/replace_if.hpp>

Description

Replaces every element in a List that satisfies a predicate by some Value .

Usage

For any List l, Lambda lbd and Values val_0, ..., val_n-1

using result = metal::replace_if<l, lbd, val_0, ..., val_n-1>;
Precondition
: For any element l[i] contained in l, metal::invoke<lbd, l[i]> returns a Number
Returns
: List
Semantics:
Equivalent to
using result = metal::list<...>;
where result contains all and only the elements in l, except that every element l[i] for which metal::invoke<lbd, l[i]>{} != false has been replaced by val_0, ..., val_n-1.

Example

See Also

See also
list, replace, copy_if, remove_if

◆ reverse

template<typename seq >
using metal::reverse = typedef metal::range<seq, metal::size<seq>, metal::number<0> >

#include <metal/list/reverse.hpp>

Description

Reverses the order of the elements of a List .

Usage

For any List l

using result = metal::reverse<l>;
Returns
: List
Semantics:
If l contains elements l[0], ..., l[m-1], then
using result = metal::list<l[m-1], ..., l[0]>;

Example

See Also

See also
list, rotate, sort

◆ rotate

template<typename seq , typename num >
using metal::rotate = typedef typename detail::_rotate<seq, num>::type

#include <metal/list/rotate.hpp>

Description

Rotates the elements of a List around a pivot.

Usage

For any List l and Number num

using result = metal::rotate<l, num>;
Returns
: List
Semantics:
If l contains elements l[0], ..., l[i-1], l[i], ..., l[m-1] and num{} % m == i, then
using result = metal::list<
l[i], ..., l[m-1], l[0], ..., l[i-1]
>;

Example

See Also

See also
list, reverse, sort

◆ size

template<typename seq >
using metal::size = typedef typename detail::_size<seq>::type

#include <metal/list/size.hpp>

Description

Returns the number of elements in a List .

Usage

For any List l

using result = metal::size<l>;
Returns
: Number
Semantics:
If l contains elements l[0], ..., l[m-1], then
using result = metal::number<m>;

Example

See Also

See also
list, empty

◆ slice

template<typename seq , typename start , typename size , typename stride = number<1>>
using metal::slice = typedef metal::transform< metal::partial< metal::lambda<metal::at>, metal::if_<metal::is_list<seq>, seq> >, metal::iota<start, size, stride> >

#include <metal/list/slice.hpp>

Description

Returns a subset of elements in a List picked at regular intervals in a range.

Usage

For any List l and Numbers st, sz and sd

Precondition
: metal::number<0>{} ≤ n{} ≤ metal::size<l>{} for all n in metal::iota<st, sz, sd>
Returns
: List
Semantics:
If metal::iota<st, sz, sd> contains Numbers num_0, ..., num_n-1, then
using result = metal::list<l[num_0], ..., l[num_n-1]>;

Example

See Also

See also
list, range

◆ sort

template<typename seq , typename lbd >
using metal::sort = typedef detail::call<detail::_sort<lbd>::template type, seq>

#include <metal/list/sort.hpp>

Description

Sorts the elements of a List according to an ordering relation.

Tip
The sorting is stable if the ordering relation is strict.

Usage

For any List l and Lambda lbd

using result = metal::sort<l, lbd>;
Precondition
: For any two Values val_i and val_j contained in l metal::expr<val_i, val_j> returns a Number
Returns
: List
Semantics:
Equivalent to
using result = metal::list<val_0, ..., val_m-1>;
where val_0, ..., val_m-1 is a permutation of the elements in l such that metal::expr<val_i, val_i+1>{} != false for all i in [0, m-2].

Example

template<typename x, typename y> // strict ordering
IS_SAME(
metal::sort<l, metal::lambda<smaller>>, // stable sorting
);
template<typename x, typename y> // partial ordering
IS_SAME(
metal::sort<l, metal::lambda<not_bigger>>, // non-stable sorting
);

See Also

See also
list, reverse, rotate

◆ splice

template<typename seq , typename num , typename other >
using metal::splice = typedef metal::join<metal::take<seq, num>, other, metal::drop<seq, num> >

#include <metal/list/splice.hpp>

Description

Splices one List into another at an arbitrary position.

Usage

For any Lists l_1 and l_2 and Number num

Precondition
: metal::number<0>{} ≤ num{} ≤ metal::size<l_1>{}
Returns
: List
Semantics:
If l_1 contains elements l_1[0], ..., l_1[i], ..., l_1[m-1], l_2 contains elements l_2[0], ..., l_2[n-1] and num{} == i, then
using result = metal::list<
l_1[0], ..., l_2[0], ..., l_2[n-1], l_1[i], ..., l_1[m-1]
>;

Example

IS_SAME(
metal::list<short, int, char, char[], long, float, double, void>
);

See Also

See also
list, insert

◆ take

template<typename seq , typename n >
using metal::take = typedef metal::range<seq, metal::number<0>, n>

#include <metal/list/take.hpp>

Description

Removes all elements from the end down to an arbitrary index of a List .

Usage

For any List l and Number num

using result = metal::take<l, num>;
Precondition
: metal::number<0>{} ≤ num{} ≤ metal::size<l>{}
Returns
: List
Semantics:
If l contains elements l[0], ..., l[i], ..., l[m-1] and num{} == i, then
using result = metal::list<l[0], ..., l[i-1]>;

Example

See Also

See also
list, range, erase, drop

◆ transform

template<typename lbd , typename... seqs>
using metal::transform = typedef detail::call< if_<same<size<seqs>...>, detail::_transform<lbd> >::template type, seqs...>

#include <metal/list/transform.hpp>

Description

Transforms one or more Lists into a new List through an arbitrary n-ary Lambda .

Usage

For any Lambda lbd and Lists l_0, ..., l_n-1

using result = metal::transform<lbd, l_0, ..., l_n-1>;
Precondition
: metal::size<l_0>{} == metal::size<>{}... == metal::size<l_n-1>{}
Returns
: List
Semantics:
Equivalent to
using result = metal::list<
metal::invoke<lbd, l[0]...>,
metal::invoke<lbd, l[1]...>,
...,
metal::invoke<lbd, l[m-1]...>,
>;
where l[N]... stands for l_0[N], ...[N], l_n-1[N].

Example

See Also

See also
list, accumulate

◆ transpose

#include <metal/list/transpose.hpp>

Description

Transposes a List of Lists.

Usage

For any List l

using result = metal::transpose<l>;
Precondition
: If l contains elements l[0], ..., l[m-1], metal::size<l[0]>{} == metal::size<>{}... == metal::size<l[n-1]>{}
Returns
: List
Semantics:
Equivalent to
using result = metal::list<
metal::list<l[0][0], ...[0], l[m-1][0]>,
...,
metal::list<l[0][n-1], ...[n-1], l[m-1][n-1]>
>;

Example

See Also

See also
list, cartesian