# Count Vowels in A list-Prolog

Page 1 of 1

## 4 Replies - 1686 Views - Last Post: 03 July 2013 - 09:02 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=323595&amp;s=e8fffd8841903e0d0577cf56ecb66f63&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Ann1

Reputation: 0
• Posts: 10
• Joined: 13-November 12

# Count Vowels in A list-Prolog

Posted 25 June 2013 - 05:07 AM

I'm new to prolog ,When I used the code below,I get the output as false
```cvowel([],0).
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.

```

Is This A Good Question/Topic? 0

## Replies To: Count Vowels in A list-Prolog

### #2 #define

• Duke of Err

Reputation: 1490
• Posts: 5,190
• Joined: 19-February 09

## Re: Count Vowels in A list-Prolog

Posted 26 June 2013 - 01:14 PM

You are passing the head of the list to the vowel predicate, H is an element of a list.

```vowel(H,Counter)

```

So you don't need a list:

```vowel(a,Counter):-Counter is 1.

or

vowel(a, 1).

```

### #3 Ann1

Reputation: 0
• Posts: 10
• Joined: 13-November 12

## Re: Count Vowels in A list-Prolog

Posted 02 July 2013 - 09:11 AM

then to hold a one value we don't need to put []
```	vowel(a,Counter):-Counter is 1.

```

### #4 #define

• Duke of Err

Reputation: 1490
• Posts: 5,190
• Joined: 19-February 09

## Re: Count Vowels in A list-Prolog

Posted 02 July 2013 - 01:42 PM

Ann1, on 02 July 2013 - 05:11 PM, said:

then to hold a one value we don't need to put []

You are correct, the square brackets are used for lists and an empty list is [].

### #5 Ann1

Reputation: 0
• Posts: 10
• Joined: 13-November 12

## Re: Count Vowels in A list-Prolog

Posted 03 July 2013 - 09:02 AM

Thank you.............