hadley/lowliner — pull request #26 by lionelgit (2014-12-21 13:42:07+00:00)
Title: Implement probe()

`probe(x, predicate)` is a shortcut meant to be the equivalent to `map_v(x, predicate, .type = logical(1))`.

The need for such a shortcut is somewhat compensated by all lowliner functions taking a predicate as argument: `keep()`, `map_if()`, ... However there are still situations where it is needed to construct a logical vector.

For example, if we use `map_if()` twice to selectively modify the list when a predicate is TRUE and an alternative modification when it's FALSE, we need to record such a logical vector because the contents of the list are altered during the first `map_if()` call. Example:
```
l <- list(a = 1, b = "2", c = "3")

is_character <- probe(l, is.character)
l <- l %>%
map_if(is_character, as.numeric) %>%
map_if(!is_character, as.character)
```

I think `probe()` would be a nice little touch of sugar and make the code a bit more expressive in these situations.