title: Calculate a list of cubes in Prolog
body: <p>So I'm doing some Prolog in SWI-Prolog and I've come across a little snag. I must create a list of cubes, given an input list. The code I currently have is </p>
  
  <pre><code>cubes([Head|Tail],Cubes) :-
      cubes([Head|Tail],Cubes,[]).
  cubes([Head|Tail],Cubes,ActualCubes) :-
      X is Head^3,
      append(ActualCubes,[X],NewCubes),
      cubes(Tail,Cubes,NewCubes).
  cubes([Tail],Cubes,ActualCubes) :-
      X is Tail^3,
      append(ActualCubes,[X],NewCubes),
      Cubes is NewCubes.
  </code></pre>
  
  <p>When I run that it gives an error, specifically...</p>
  
  <pre><code>ERROR: '.'/2: Type error: `[]' expected, found `[8]' ("x" must hold one character)
     Exception: (7) cbList([1, 2], _G296, []) ? creep
  </code></pre>
  
  <p>I'm not entirely sure why this error is occurring but it seems to happen around the very last line, Cubes is NewCubes. Any help is appreciated :)</p>