title: Sum of rows in a matrix with lisp
body: <p>I'm doing some LISP exercises using functions <code>mapcar</code> and <code>apply</code>. I'm dealing with matrixes, and I have to sum its rows and columns. For column I have:</p>
  
  <pre><code>(apply #'mapcar #'+ matrix)
  </code></pre>
  
  <p>That works. Since I know how to transpose a matrix, I can do the exact same thing for the rows right? Right, that would be:</p>
  
  <pre><code>(apply #'mapcar #'+ (apply #'mapcar #'list matrix))
  </code></pre>
  
  <p><strong>But I'm not happy</strong> <strong>with that</strong>. I want to sum the row directly, so I did a <code>mapcar</code> of <code>apply</code>:</p>
  
  <pre><code>(mapcar #'apply #'+ matrix)
  </code></pre>
  
  <p>that <strong>doesn't</strong> work and I don't know why. The error is </p>
  
  <blockquote>
    <p>The value #(FUNCTION +) is not of type LIST.
       [Condition of type TYPE-ERROR]</p>
  </blockquote>
  
  <p>For me, that would get every list inside matrix, and apply the sum in each one. I cannot make a <code>mapcar</code> of <code>apply</code>? If no, why not? Is there another way to sum the rows of a matrix using just <code>mapcar</code> and <code>apply</code>?</p>
  
  <p>PS: I'm using lispstick to compile and the matrix is a list of lists. Example</p>
  
  <pre><code>((1 1 1) (2 2 2) (3 3 3))
  </code></pre>
  
  <p>for a 3x3 matrix.</p>