Skip to content

Instantly share code, notes, and snippets.

@bestdan
Last active April 18, 2019 14:44
Show Gist options
  • Save bestdan/ebd98faff09be656896cbeebb9d42344 to your computer and use it in GitHub Desktop.
Save bestdan/ebd98faff09be656896cbeebb9d42344 to your computer and use it in GitHub Desktop.
Simple examples of lines of code
# Version 1: LOC incentive --> inflated code
add_up = function(inputs){
total = inputs[1]
for i in 2:length(inputs){
total = total + inputs[i]
}
return(total)
}
# Version 2: LOC costs you
add_up = function(inputs){
return(sum(inputs))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment