A set of optics specific to lists.
all/0 | |
all/1 | Focus on all elements of a list. |
head/0 | |
head/1 | Focus on the head of a list. |
nth/1 | |
nth/2 | Focus on the nth element of a list. |
tail/0 | |
tail/1 | Focus on the tail of a list. |
all() -> optic:optic()
See also: all/1.
all(Options) -> optic:optic()
Options = optic:variations()
Options
: Common optic options.
returns: An opaque optic record.
Focus on all elements of a list.
Example:
> optic:get([optic_lists:all()], [1,2,3]).
{ok,[1,2,3]}
head() -> optic:optic()
See also: head/1.
head(Options) -> optic:optic()
Options = optic:variations()
Options
: Common optic options.
returns: An opaque optic record.
Focus on the head of a list. The list must have at least one element to have a head.
Example:
> optic:get([optic_lists:head()], [1,2,3]).
{ok,[1]}
nth(N) -> optic:optic()
N = pos_integer()
See also: nth/2.
nth(N, Options) -> optic:optic()
N = pos_integer()
Options = optic:variations()
N
: The index of the list element to focus on.Options
: Common optic options.
returns: An opaque optic record.
Focus on the nth element of a list. As with lists:nth/2
, indexing
begins at 1.
Example:
> optic:get([optic_lists:nth(1)], [1,2,3]).
{ok,[1]}
tail() -> optic:optic()
See also: tail/1.
tail(Options) -> optic:optic()
Options = optic:variations()
Options
: Common optic options.
returns: An opaque optic record.
Focus on the tail of a list. A list must have at least one element to have a tail.
Example:
> optic:get([optic_lists:tail()], [1,2,3]).
{ok,[2,3]}