Split a List into smaller lists of N size
<p>I am attempting to split a list into a series of smaller lists.</p>

<p><strong>My Problem:</strong> My function to split lists doesn't split them into lists of the correct size. It should split them into lists of size 30 but instead it splits them into lists of size 114?</p>

<p>How can I make my function split a list into X number of Lists of size <strong>30 or less</strong>?</p>

<pre><code>public static List&lt;List&lt;float[]&gt;&gt; splitList(List &lt;float[]&gt; locations, int nSize=30) 
{       
    List&lt;List&lt;float[]&gt;&gt; list = new List&lt;List&lt;float[]&gt;&gt;();

    for (int i=(int)(Math.Ceiling((decimal)(locations.Count/nSize))); i&gt;=0; i--) {
        List &lt;float[]&gt; subLocat = new List &lt;float[]&gt;(locations); 

        if (subLocat.Count &gt;= ((i*nSize)+nSize))
            subLocat.RemoveRange(i*nSize, nSize);
        else subLocat.RemoveRange(i*nSize, subLocat.Count-(i*nSize));

        Debug.Log ("Index: "+i.ToString()+", Size: "+subLocat.Count.ToString());
        list.Add (subLocat);
    }

    return list;
}
</code></pre>

<p>If I use the function on a list of size 144 then the output is:</p>

<blockquote>
  <p>Index: 4, Size: 120<br>
  Index: 3, Size: 114<br>
  Index: 2, Size: 114<br>
  Index: 1, Size: 114<br>
  Index: 0, Size: 114</p>
</blockquote>
