RosettaCodeData/Task/Substring-Top-and-tail/R/substring-top-and-tail.r

5 lines
170 B
R
Raw Permalink Normal View History

2025-08-11 18:05:26 -07:00
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)