How compute Index of element in a list?

I am starting to play with prolog, and with a Java background it's really difficult for me so here is a silly question:

How will you write an indexOf predicate able to give the index of a given element in a given list ?

My first question is about the predicate arity: I guess it should be 3 such as:

indexOf(List,Element, Index) :- ......

Am I right ? May be this already exists in built-in libraries but I want to learn how to write it. Thanks for your help.

9
задан false 23 January 2014 в 16:21
поделиться