library(purrr)
library(rlang)
#>
#> Attaching package: 'rlang'
#> The following objects are masked from 'package:purrr':
#>
#> %@%, as_function, flatten, flatten_chr, flatten_dbl, flatten_int,
#> flatten_lgl, flatten_raw, invoke, list_along, modify, prepend,
#> splice
# "closure"s work for .f in map()
typeof(seq)
#> [1] "closure"
map(c(1L, 3L), seq, to = 5L, by = 1L)
#> [[1]]
#> [1] 1 2 3 4 5
#>
#> [[2]]
#> [1] 3 4 5
# "builtin"s do not work for .f in map()
typeof(seq.int)
#> [1] "builtin"
map(c(1L, 3L), seq.int, to = 5L, by = 1L)
#> Error in .f(.x[[i]], ...): argument "length.out" is missing, with no default
# Investigation
# * `map` calls `as_mapper(.f, ...)`, which dispatches to `purrr:::as_mapper.default`
# * `as_mapper.default` calls `rlang::as_closure`
# Generates the same error:
as_closure(seq.int)(1L, to = 5L, by = 1L)
#> Error in as_closure(seq.int)(1L, to = 5L, by = 1L): argument "length.out" is missing, with no default
Created on 2020-05-06 by the reprex package (v0.3.0)