Skip to content

Instantly share code, notes, and snippets.

@vankesteren
Created April 16, 2018 07:47
Show Gist options
  • Select an option

  • Save vankesteren/20959d95629387b440ffd9f9f5fdef42 to your computer and use it in GitHub Desktop.

Select an option

Save vankesteren/20959d95629387b440ffd9f9f5fdef42 to your computer and use it in GitHub Desktop.
ints <- function(start, end) {
if (start > end) return(NULL)
return(c(start, ints(start + 1, end)))
}
@vankesteren

Copy link
Copy Markdown
Author

code golf style

i<-function(s,e){if(s>e)return();c(s,i(s+1,e))}

@vankesteren

Copy link
Copy Markdown
Author

even shorter

i<-function(s,e)if(s<=e)c(s,i(s+1,e))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment