Basically what I'm trying to do here is make a predicate "first" which takes first C members from a list and makes a new list out of them in the same arrangement. e.g. first([a,b,c,d,e],3,R). would return R = [a,b,c]. Now I'm getting an infinite loop and cannot find the cause of that. Thanks for your help.
first([],_,[]).
firts([_], 0, []).
first([H|T], C, R):- C >= 1,
append(R, [H], R2),
C2 is C - 1,
first(T, C2, R2).