RosettaCodeData/Task/Substring-Top-and-tail/R/substring-top-and-tail.r
2025-08-11 18:05:26 -07:00

4 lines
170 B
R

top_and_tail <- function(s, top=TRUE, tail=TRUE) substr(s, 1+top, nchar(s)-tail)
top_and_tail("xyzzy")
top_and_tail("xyzzy", top=FALSE)
top_and_tail("xyzzy", tail=FALSE)