Solved

Haskell -

Posted on 2006-11-05
2
208 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
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

This is about my first experience with programming Arduino.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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 fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now