<- list(c(2, 7, 9))
x1 1]] x1[[
[1] 2 7 9
<- list(list(c(2, 7, 9)))
x2 1]][[1]] x2[[
[1] 2 7 9
<- list(c(2, 7, 9), list("a", "b"))
x3 1]] x3[[
[1] 2 7 9
<- list(c("a", "b"), list(list(c(2, 7, 9))))
x4 2]][[1]][[1]] x4[[
[1] 2 7 9
<- list(c(2, 7, 9))
x1 1]] x1[[
[1] 2 7 9
<- list(list(c(2, 7, 9)))
x2 1]][[1]] x2[[
[1] 2 7 9
<- list(c(2, 7, 9), list("a", "b"))
x3 1]] x3[[
[1] 2 7 9
<- list(c("a", "b"), list(list(c(2, 7, 9))))
x4 2]][[1]][[1]] x4[[
[1] 2 7 9
<- list("a", "b", list("c", list(c(2, 7, 9))))
x5 3]][[2]][[1]] x5[[
[1] 2 7 9
<- list(function(x) {return(x^2 - x)},
fun_list function(x) {return(sin(x) + cos(x))},
function(x) {return(exp(x)/x)})
integrate
function is actually a list! So it makes sense to store each result in a list:<- list()
integral
for(i in 1:length(fun_list)){
<- integrate(fun_list[[i]], 1, 2)
integral[[i]]
}
integral
[[1]]
0.8333333 with absolute error < 9.3e-15
[[2]]
1.024276 with absolute error < 1.1e-14
[[3]]
3.059117 with absolute error < 3.4e-14