Biology, asked by amanmeena4692, 1 year ago

To find the nth element of a given list in prolog

Answers

Answered by jakeer1
0
I am trying to write a Prolog code finding the n-th element of a list. I wrote the below code but it doesn't return the element right.

match([Elem|Tail],Num,Num,Elem).
match([Elem|Tail],Num,C,MatchedNumber):-
match(Tail,Num,N,Elem),
C is N+1.
Similar questions