Open danklotz opened 7 years ago
even better solution
a1 <- "//my_path//my_folder"
a2 <- "my_path/my_folder/"
b <- "my_prog"
'%+/%' <- function(a,b) {
ifelse( substr(a,nchar(a),nchar(a)) == "/",
paste(a,b, sep =""),
paste(a,b, sep = "/"))
}
a1 %+/% b
# [1] "//my_path//my_folder/my_prog"
some ideas for possible the operator signs:
%///%
%?/%
%/|//%
%>-(((°>% # fish :D
%:p% # licking a stamp
%add%
%and%
%//-/%
%-/%
I am not sure yet if it is a good idea, but what do you think about an operator which robustly paste path together, by always adding a
/
while avoiding//
sign (I often do not want to have '//' sings in the string for pasting reasons). The realisation could look something like this:Example: