?
Solved

Haskell -

Posted on 2006-11-05
2
Medium Priority
?
213 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 2000 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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 …
Six Sigma Control Plans
Suggested Courses

777 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