I have a little rule in prolog that has to check if an element is a member of a list and write it\'s position in the list,but it only works if the elemebt i\'m looking for is in
Since you report it's working only for the first position, here is the simpler correction possible to your code to make it work in other cases:
write_element(X,[X|_],1). write_element(X,[_|Tail],N):- write_element(X,Tail,N1), N is N1 + 1.
but the answer from Daniel (+1) is what you should study.