Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7489493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:15:23+00:00 2026-05-29T15:15:23+00:00

I am trying to count vowel groups in a sentence. My first attempt was

  • 0

I am trying to count vowel groups in a sentence.

My first attempt was to use list comprehension to reduce the sentence to a list of boolean values for each Char, depending on if it is a vowel or not. However, I’m not sure how to count the groups of consecutive “True” values in the list. Is there any trick to do this?

It was located in my textbook in a chapter dealing with lists and list comprehension, so I feel it has something to do with that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T15:15:24+00:00Added an answer on May 29, 2026 at 3:15 pm

    Since I don’t know whether it’s a homework, I’m going to give you hints:

    In Data.List:

    group :: Eq a => [a] -> [[a]]
    -- also interesting: groupBy :: (a -> a -> Bool) -> [a] -> [[a]]
    
    -- for example:
    -- group [True, True, False, False, False, True] =
    -- [[True, True], [False, False, False], [True]]
    

    You can write your own:

    isVowel :: Char -> Bool
    

    So you should be able to get the list you mention, with Bools, and now you want to count the groups that are “all True”.

    and :: [Bool] -> Bool
    or :: [Bool] -> Bool
    

    Any of these two fellows should prove useful, since both can reduce a list of all-equal boolean values into a single value equal to them.
    (EDIT: As mentioned in a comment, I’m overworking here, you just need to take the head of each “group”. In fact, you can also guess the number of vowel groups just by looking at whether the first group is a vowel/consonant, and by counting the number of groups, since for sure there is an alternation vowel/consonant!)

    And now, you just need to count the Trues in this final list, since each True represents a group of vowels!

    filter :: (a -> Bool) -> [a] -> [a]
    length :: [a] -> Int
    

    You should be able to do the plumbing by yourself with these indications!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to count all the values inside an array, I've tried using count()
I am trying to count string values in a member of an object. I
I'm trying to count the nested elements in a multidimensional array. At first I
I'm trying to count the number of times each letter appears in a file.
I'm trying select count(*) from groups left join members on groups.id=members.group_id group by groups.id
I'm trying to count the number of rows that have distinct values in both
I am trying to count the total number of clock ticks for each process
I am trying to count how many products are associated with each of our
Im trying count the number of positive elements in a list. Here is what
Trying to count how many elements within the array are not equal to 0,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.