title: Prolog - dividing list into n-elements sections
body: <p>I have a predict which gets first N elements:</p>
  
  <pre><code>nfirst(N, _, Lnew) :- N =&lt; 0, Lnew = [].
  nfirst(_, [], []).
  nfirst(N, [X|Y], [X|Y1]) :- N1 is N - 1, nfirst(N1, Y, Y1).
  </code></pre>
  
  <p>It works:
     % nfirst(3,[1,2,3,4,5,6],X).
     % X = [1, 2, 3]</p>
  
  <p>I need a predict for divide list like below:</p>
  
  <pre><code>% divide([a,b,c,d,e,f,g,h],[3,2,1,2],X).
  % X = [[a,b,c],[d,e],[f],[g,h]]
  </code></pre>
  
  <p>The best way is using nfirst.</p>