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 7843217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:30:05+00:00 2026-06-02T16:30:05+00:00

Im learning haskell and I got a problem. The type must be: sentences ::

  • 0

Im learning haskell and I got a problem.
The type must be: sentences :: [String] -> [String]

I want to convert strings into a sentence

["something","","Asd dsa abc","hello world..",""] 

to look like this: ["Something.","Asd dsa abc.","Hello world..."]

And I want to use a higher-order function like map.
I just cant figure out how to make this.

I managed to work with a single string:

import Data.Char
sentences :: String -> String
sentences [] = []
sentences (a:as) = (( toUpper a):as) ++ "."

So I get from this:

sentences "sas das asd"

this: "Sas das asd."

I hope someone can help me with this problem.
Thanks for your help!

Edit: Thanks for your help now it looks like this:

import Data.Char
sentences :: [String] -> [String]
sentence (a:as) = ((toUpper a):as)++['.']
sentences = map sentence

But i dont know where to put the filter

  • 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-06-02T16:30:06+00:00Added an answer on June 2, 2026 at 4:30 pm

    Your function coupled with map gets you half of the way, but it does not remove the empty strings from your list of strings. You can do this with filter, so in total

    sentences ss = map sentence $ filter (/="") ss
    

    Note that the core of sentences (plural) is simply the mapping of sentence (singular) over your list of strings. The filter is only there to remove the empty strings. Without this requirement, it would simply be sentences ss = map sentence ss.

    Now you can call sentences with your list of strings to have each element transformed, except the empty strings that are removed by filter

    In general, if you have a function foo that transforms bar into baz, you can use map foo to transform [bar] into [baz]

    filter, like map, is a higher order function which, given a predicate function and a list, returns a list consisting of the elements for which the predicate is True. In this case, we give the predicate function (/=""), which is True for all strings that are not empty.

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

Sidebar

Related Questions

I just started learning Haskell and I ran into a problem in 2-adic type
I started learning haskell yesterday and I got stuck on a problem. After a
I've recently been learning Haskell, and I noticed that the String type (or [Char]
I'm learning Haskell now and I'm facing the following problem: I want to rewrite
I'm still learning Haskell and need help with the type inference please! Using packages
I am learning Haskell and I want to do TDD. I am trying to
I just started learning Haskell. I think I've got the basics down, but I
Learning haskell and want a function to generate a 2D grid similar to how
I'm learning Haskell and stuck trying to understand the type system. I'm trying to
I recently started learning Haskell and I'm trying to rewrite something I did for

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.