title: How can i find the sum of a list of functions in R?
body: <p>So i have a list of functions.I want to create a for loop that returns (obviously as a function) the sum of them.</p>
  
  <p>In order to create a list of functions inside a for loop i am using this code</p>
  
  <pre><code>##CODE
  
  f=dnorm
  h=function(x){log(f(x))}
  
  S=c(-3,-2,-1,0,1,2,3)
  K=matrix(rep(1:length(S),2),ncol=2)
  
  for(i in 1:length(S)){
     K[i,]=c(S[i],h(S[i]))
    }
  
  funcs=list()
  
  ## LOOP TO DEFINE THE LINES
  
  for(i in 1:6){
  
  ## Make function name
  funcName &lt;- paste( 'hl', i,i+1, sep = '' )
  
  ## Make function 
  func1 = paste('function(x){  (K[',i,'+1,2]-K[',i,',2])/(K[',i,'+1,1]-K[',i,',1])*x+ 
  K[',i,'+1,2]-((K[',i,'+1,2]-K[',i,',2])/(K[',i,'+1,1]-K[',i,',1]))*K[',i,'+1,1]}',sep 
  = '')
  
  funcs[[funcName]] = eval(parse(text=func1))
  
   }
  </code></pre>
  
  <p>which creates a list of 6 functions. How can I get their sum? I tried using the apply commands but either my syntax is not correct or they do not work.</p>
  
  <p>P.S I am actually trying to write my one code for the ars command.</p>