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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:23:57+00:00 2026-05-31T20:23:57+00:00

I have a fully functional redact program written in haskell.it replaces all the words

  • 0

I have a fully functional redact program written in haskell.it replaces all the words that you input with starts.However i have a problem with the command line arguments.
If you type in:

cat poem.txt | redact word1 word2 word3

it only redacts word1

if you write

cat poem.txt | redact “word1 word2 word3”

it redacts all 3 words…this is probably some kind of mistake i did with the command line arguments…here is my code

module Main where

import System
import Data.Char
import Data.Bits

convertWord :: Eq a=> [a] -> String
convertWord = map (const '*')

lowercase :: [Char]->[Char]
lowercase ch = map toLower ch

redact :: String -> String -> String
redact text keywords = unlines(map unwords redactedtext)
         where redactedtext = map processed text1
               text1        = map words (lines text)
               processed    = map tobeconverted
               keywords1    = words keywords
               tobeconverted x | lowercase x `elem` map lowercase keywords1     =   convertWord x
                               | otherwise                                      = x


main = do
   text <- getContents
   (key:_) <- getArgs
   let   
          result = redact text key




   putStr (result)
  • 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-31T20:23:59+00:00Added an answer on May 31, 2026 at 8:23 pm

    The point is this:

    (key:_) <- getArgs
    

    Here you explicitly ignore everything but the first argument.

    If redact function would take a list of keywords, you could just pass through the whole list of arguments you get from getArgs:

    keys <- getArgs
    let result = redact text keys
    

    Note that this way, your redact function actually gets a bit easier, because you do not have to split words.
    In addition, you whole program gets safer, because it does not abort when no arguments are given.

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

Sidebar

Related Questions

I have a fully-functional Java program that's fairly long, and I want to transfer
I have created a functional OOP program that uses a bunch of classes, and
In Vaadin's website it says that only Eclipse and NetBeans have fully functional (which
We currently have a fully functional Gui written created using PyQt. My partner wrote
I work for local notification and all I have built fully functional And follows
I have a datepicker that is fully functional and is working whereby you can
I have been looking for a fully functional WSDL client generator for ruby. I
I have a fully working Setup project within Visual Studio 2008 that takes inputs
This is something that I have never fully grasped in .NET as to the
I have a database table on a development server that is now fully populated

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.