I have a very simple Prolog function but Prolog always returns false from the comparison and I can't work out why. I want to take N letters of the alphabet and put them in a list. So if I call it with N=6, I want [A,B,C,D,E,F]. Can anyone tell me what I'm doing wrong please?
create([],_,_,[]).
create([X|XS],Length,Acc,[X|NewList]) :-
Acc<Length, create(XS,Length,Acc+1,NewList).
I get this when I run it using SWIPL:
?- create([A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z],6,0,Nodes).
false.
But if I take out the Acc<Length it creates a list of 26 letters:
?- create([A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z],6,0,Nodes).
NewList = [A, B, C, D, E, F, G, H, I|...].