List | R Documentation |
The list
built-in type is a monad with element-wise function application
as fmap()
and flattening as join()
. It follows that %>>%
is a map
operator and %>-%
is a "flat map" operator. The methods are implemented
as wrappers to the purrr package.
purrr::map()
which implements fmap()
for list
.
purrr::list_flatten()
which implements join()
for list
.
Other monads:
Maybe
# The fmap operator corresponds to purrr::map().
list(1, 2) %>>% `+`(1)
# The bind operator is a "flat map" that combines output lists.
list(1, 2) %>-% \(x) list(x * 2, x / 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.