title: disadvantage of pure function in functional programming
body: <p>A pure function in functional programming is the one which do not have side effects. One of the meanings of this is it can not change the values of input parameters. Can this be seen as disadvantage for the memory utilization? <br>
  e.g. Lets say I have a function which simply takes a list and add another element in it. In C++ it could be as simple as <br></p>
  
  <pre>
  <code>
  void addElem(std::vector& vec, int a)
  {
      vec.insert(a);
  }
  </code>
  </pre>
  
  <p>This function clearly doesn't use much memory than already taken by passed object.<br>
  But same in Haskell will come to something like this. <br></p>
  
  <pre>
  addElem :: [Int] -> Int -> [Int] 
  addElem xs a = xs ++ [a]
  </pre>
  
  <p>Now in this computation as xs is not changing it's value. So am I correct in saying that at some time the function will be consuming the memory double size of  xs, one for xs and other for the return value. Or somehow lazy invocation makes sure that actually xs is only getting returned by adding only one element at the end? <br>
  I know that Monad is the way to have something which can have side effect. But can Monad be used to simply modify the input and return it's value?<br>
  Also can changing xs ++ [a] to a:xs consumes less memory? </p>