chrisschuerz / pasta

Intuitive and readable infix functions to paste strings together
8 stars 0 forks source link

Collapse #1

Open danklotz opened 7 years ago

danklotz commented 7 years ago

The package misses a method to colapse the generated strings. Currently one has to do something like this

library(pasta)
library(magrittr)
# 
raw_strings <- c("a","b")
new_string <-  (raw_strings %_% 1) %>% paste(., collapse = "-")

So I think we might just wrap paste(x, collapse = "y") to a function within pasta, e.g.:

bind <- function(x, with = y) {
    paste(x, collapse = "with")
}

We would loose almost nothing if we could find a good name 😀

chrisschuerz commented 7 years ago

I am not fully convinced, as the new bind function does exactly the same as paste. Its structure is completely the same when calling it.

Regarding the naming; what about tie(), splice(), link(), or noodle() :relaxed:

danklotz commented 7 years ago

mh... yeah. Then maybe several functions that come with pre-set collapses? E.g.

tie <- function(x) {
    paste(x, collapse = "")
}

bind <- function(x) {
    paste(x, collapse = " ")
}

link <- function(x) {
    paste(x, collapse = "-")
}

So reducing flexibility for better expression?

danklotz commented 7 years ago

more words: strap, bond and my favourine "knot" (like knit, but knot 💃)