Description Usage Arguments Format Value See Also Examples
Similar to "bind" but maybe_map passes its argument to the continuation function and evaluates the resulting expression immediately rather than wrapping it in an anonymous function to be evaluated later. This is particular useful when using magrittr piping operators to compose chains of function calls.
1 | maybe_map(m, f)
|
m |
A Maybe (two-track) value. |
f |
A function taking a non-optional (one-track) argument and returning a non-optional (one-track) value. |
maybe_map :: Maybe a -> (a -> b) -> Maybe b
A Maybe (two-track) value
Other Maybe functions: as_maybe
,
is_nothing
, maybe_apply
,
maybe_bind
, maybe_default
,
maybe_map_2
, maybe_map_3
,
maybe_map_4
, maybe_map_5
,
maybe_then
, maybes_collapse
,
maybes_partition
1 2 3 4 5 | library("magrittr")
library(assertthat)
Just(1) %>% maybe_map(is.numeric) # Just(TRUE)
Just("cat") %>% maybe_map(is.numeric) # Just(FALSE)
Nothing() %>% maybe_map(is.numeric) # Nothing()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.