Solved

Haskell -

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is an explanation of a simple data model to help parse a JSON feed
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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 …

706 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

18 Experts available now in Live!

Get 1:1 Help Now