Solved

Haskell -

Posted on 2006-11-05
2
210 Views
Last Modified: 2010-04-16
Given that I have the following function:

-- This function constructs InputData where InputData is either a line of words ex "Hi there. Oh it's Bob!" or
-- it is a word in which to search the string  ex "?Bob"
inputline :: String -> InputData
inputline (x:xs)
  | x == '?' =  Search xs
  | otherwise = Line (x:xs)

so for example:
inputline "hello bob"
returns > Line "hello bob"

What I can figure out is how to pass this inputline data type into a function, and then return just the string part.  

Help please??
0
Comment
Question by:twibblejaway
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
VoteyDisciple earned 500 total points
ID: 17878791
I've never seen Haskell before, but I'm gonna take a shot and suppose it works similar to OCaml in its pattern matching:

undoit  :: InputData -> String
undoit (Line (x))
    = x
0
 

Author Comment

by:twibblejaway
ID: 17879185
Very nice shot
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question