# 12-1 Simple functions

### Function Definition ###

# Triple - pass by value

triple <- function(x) # Take in a single object x
{
  x<-x*3 # Multiply x by 3
  x # Evaluate the new value of x ready to return
}

### Main Script ###

a<-5
triple(a) # Displays return value of triple(a)
a # Leaves original value of a unchanged

b<-c(2.1,5.3,7.9)
triple(b) # Handles floats just as easily as integers
b

c<-c(TRUE,FALSE,TRUE)
triple(c) # Handles Booleans because they are stored as 0,1
c

d<-c("A","B","C")
triple(d) # Fails as R can't do maths with strings
d