Les fonctions
Pour créer une fonction on écrit :
<- function() { # create a function with the name my_function
my_function print("L'ISTOM c'est top!")
}
my_function()
On peut créer des fonctions avec des arguments :
<- function(promo,groupe) {
ma_promo paste("Promotion", promo, "groupe", groupe)
}
ma_promo(114,"A")
ma_promo(115,"B")
On a également :
<- function(x) {
ma_multiplication return (5 * x)
}
print(ma_multiplication(3))
print(ma_multiplication(5))
print(ma_multiplication(9))