title: Storing a google spreadsheet array in one cell
body: <p>Is it possible to store a google spreadsheet array in one cell, and then to refer to it?</p>
  
  <p>I have a table, from which I have used FILTER to gather an array of relevant lines. I need to do several things with the filtered array: count the number of elements and sum the elements. Currently I have to repeat the FILTER function several times, because I can't host its output in one cell. It would be much nicer to store the FILTER output in a cell, and then have another cell with, say, "=SUM(B1)", and "=COUNT(B1)".</p>
  
  <p>I have found that NOEXPAND disables adding CONTINUE cells, but then if I write "=COUNT(B1)" the result is 1 - I'm counting only the first item of the array.</p>
  
  <p>Thanks!</p>
  
  <p>edit: For some reason I couldn't answer my own question, but I found out that you can write your own functions in javascript. You can even serialize an array with JSON, and keep the result as a string. So, as a basic example, you can write:</p>
  
  <pre><code>function serialize(a) {
    return JSON.stringify(a);
  }
  
  function deserialize(a) {
    return JSON.parse(a);
  }
  </code></pre>