Arity Prolog:
min([H],H).
min([H|Tail],H):-min(Tail,Min1),H=
min([_|Tail],Min):-min(Tail,Min).
numbers(L,N):-min(L,Min),numbers(L,1,Min,N).
numbers([],_,_,[]).
numbers([Min|Tail],I,Min,[I|TailIndex]):-!,I1 is I+1,numbers(Tail,I1,Min,TailIndex).
numbers([_|Tail],I,Min,TailIndex):-I1 is I+1,numbers(Tail,I1,Min,TailIndex).
?- numbers([1,2,6,1,8,3,1],N).
N = [1, 4, 7].
|