I need to define divide so that List [1,2,3,4,5] divides into:
a = [1,2,3}
b = [4,5]
I\'m getting an error that says \"         
        
This is how I did it. Almost no built-ins:
split_list_in_half( Xs , H , T ) :-
  list_length( X , L ) ,
  LL = L - (L // 2) ,
  take_first( Xs , LL , H , T ) ,
  .
list_length( L , N ) :-
  list_length( L , 0 , N )
  .
list_length( [] , N , N ).
list_length( [X|Xs] , T , N ) :-
  T1 is T+1 ,
  list_length( Xs , T1 , N )
  .
take_first( Xs , N , Pfx , Sfx ) :-
  take_first( Xs , N , [] , P1 , Sfx ) ,
  reverse( P1 , Pfx )
  .
take_first( []     , _ , H  , H , []     ).
take_first( [X|Xs] , 0 , H  , H , [X|Xs] ).
take_first( [X|Xs] , N , H1 , H , T      ) :-
  N > 0    ,
  N1 = N-1 ,
  take_first( Xs , N1 , [X|H1] , H , T )
  .