effect of tilda in purrr::map

Viewed 34

Regarding the discussion here and map documentation ("If character vector, numeric vector, or list, it is converted to an extractor function"), shouldn't the following two statements result in the same output? map documentation :

map(1:3,  function(x){x[runif(2)]})
[[1]]
integer(0)

[[2]]
integer(0)

[[3]]
integer(0)

and

map(1:3,  runif(2))
[[1]]
NULL

[[2]]
NULL

[[3]]
NULL

I wonder why the outputs are different.

0 Answers
Related