hadley/lowliner — pull request #24 by lionelgit (2014-12-15 19:41:14+00:00)
Title: Implement `cross()`

This is a trimmed down version of `expand.grid()` that takes a list as input and return a list.

Example:

```
data <- list(
id = c("John", "Jane"),
greeting = c("Hello.", "Bonjour."),
sep = c("! ", "... ")
)
args <- cross(data)

out <- vector("list", length(args[[1]]))
for (i in seq_along(out))
out[[i]] <- map(args, i) %>% splat(paste)()
out

## [[1]]
## [1] "John! Hello."
##
## [[2]]
## [1] "Jane! Hello."
##
## [[3]]
## [1] "John! Bonjour."
##
## [[4]]
## [1] "Jane! Bonjour."
##
## [[5]]
## [1] "John... Hello."
##
## [[6]]
## [1] "Jane... Hello."
##
## [[7]]
## [1] "John... Bonjour."
##
## [[8]]
## [1] "Jane... Bonjour."
```