When I used the code though there ara no I won't get anwser.I couldn't whatis the error I did.

vowel([a],Counter):-Counter is 1.
vowel([e],Counter):-Counter is 1.
vowel([i],Counter):-Counter is 1.
vowel([o],Counter):-Counter is 1.
vowel([u],Counter):-Counter is 1.
vowel([_];[],Counter):-Counter is 0.
cvowel([H|T],Counter1):-cvowel(T,Count),vowel(H,Counter),Count is Count

+Counter,Counter1 is Counter1+Count.

answer I got "Faulse"

4 Years
Discussion Span
Last Post by pyTony

Count is Count in your clause in line 8 does not make sense for me, why :- Counter is 1.?
Why not simple facts like line 1?


They do, but vowel([a], 1) is shorter.

Count is Count in your clause in line 8 does not make sense for me

Actually it's saying Count is Count + Counter (the lines are broken funnily), but that doesn't make sense either. Once a variable has been given a value, you can't just give it a new value. It will keep that value as long as it lives (or until Prolog backtracks back to a point before the variable has been given a value).

Something like X is X+Y will always be false unless Y is 0, in which case it will be true. Either way it will never change the value of X.

PS: This has also been asked and partially answered here: http://www.dreamincode.net/forums/topic/323595-count-vowels-in-a-list-prolog/

This topic has been dead for over six months. 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.