I need to get each index of all positive elements in the list and create a new list with all of these indexes
For example,
[-1,2,-5] -> [1]
[1,2,-5] -> [0,1]
I've already had a predicate to get index, but I do not understand how to iterate through each value and return a list at the end. Right now my predicates looks like
indexOf([Element|_], Element, 0) :- !.
indexOf([_|Tail], Element, Index) :-
indexOf(Tail, Element, Index1),
!,
Index is Index1+1.
iterate([],Res) :- Res.
iterate([H|T],Res) :-
H>0,
indexOf([H|T],H,Ind),
append([],[Ind],Res),
iterate(T,Res).
iterate([H|T],Res) :-
H=<0,
iterate(T,Res).
But after compilation, I receive this error
**Input**
iterate([-1,-2,3],X).
**Output**
Sandbox restriction!
Could not derive which predicate may be called from
call(C)
iterate([],A)
iterate([3],A)
iterate([-2,3],A)
iterate([-1,-2,3],A)
Pls, tell me, what I'm doing wrong? And why this error appears