I write count the letters in a list,

ERROR: countvowels/2: Arguments are not sufficiently instantiated

I got this error" why is that?
this is the coding I used

countvowels([H|T],Count1):-Count is Count1 + 1,countvowels(T,Count),Count1>1.
3 Years
Discussion Span
Last Post by Dili1234
Featured Replies
  • 1

    You need to move `Count1 is Count + 1` after the recursive call to `countvowels`. Otherwise `Count` doesn't have a value yet at that point. Read More

Count is Count1 + 1

I think you meant Count1 is Count + 1 here.

PS: As your code is currently written, it counts any item in te given list - not just vowels.


yes first tried to count any value...............
but though I changed I'm still getting that error

Edited by Dili1234


Oh, yes, you also need to move that part after the recursive call. Otherwise Count doesn't have a value at that point either.

Lastly you need to remove the Count1 > 1 bit. Otherwise it would produce False when given a list with only one element and thus, due to the recursion, when given any non-empty list.


Still I'm getting the same error,In the terminal I entered the data like this


After making all the changes I mentioned, the code works fine for me. Can you post your current version of the code?


I got it when change the coding like this

countvowels([],Count1):-Count1 is 0.
countvowels([H|T],Count1):-countvowels(T,Count),Count1 is Count + 1.

But when change that like this

countvowels([],Count1):-Count1 is 0.
countvowels([H|T],Count1):-countvowels(T,Count),Count>1,Count1 is Count + 1.

I got the answer as false why is that?

Edited by Dili1234


You need to move Count1 is Count + 1 after the recursive call to countvowels. Otherwise Count doesn't have a value yet at that point.


Let's say you pass in a list with one element. Then Count will be 0 (because the length of T will be 0). Therefore Count > 1 will be false and since there are no alternatives, the whole thing will be false. The same thing will be true if you pass in two elements (because 1 > 1 is still false) or even if you pass in more elements than that (because eventually you'll recurse down to a list that has less than 2 elements).

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.