String function examples, C/C++ Programming

1. De ne a function chomp :: String -> String that selects a run of repeated characters from the start of a string with the run being as long as possible.

For example

chomp "aaaaaabbbbcccc" = "aaaaaa"
chomp "ddddddddddddd" = "ddddddddddddd"

2. Using chomp, de ne a function
runs :: String -> [String ]
that splits a string into a list of runs of repeated characters, with each run comprising at most nine characters. For example:
runs "aaaaaabbbbcccc" = ["aaaaaa", "bbbb", "cccc"]
runs "ddddddddddddd" = ["ddddddddd", "dddd"]

3.De ne a function
flatten :: [(Char, Int)] -> String
that
attens a list of pairs of characters and digits to a string. For example:
flatten [(a, 5), (b, 4), (c, 2)] = "a5b4c2"
flatten [(d, 9), (d, 3)] = "d9d3"

Posted Date: 3/1/2013 3:03:56 AM | Location : United States







Related Discussions:- String function examples, Assignment Help, Ask Question on String function examples, Get Answer, Expert's Help, String function examples Discussions

Write discussion on String function examples
Your posts are moderated
Related Questions
A: The simplest instance of a smart pointer is auto_ptr that is included in the standard C++ library. Auto Pointer only takes care of Memory leak & does nothing regarding dangling

Write a program to print a digital clock which displays the time for 2 hours .

Write a program to determine V c for a given value of time (t)   #include stdio.h #include math.h void main() {      char prompt;   float vs,cr,t,vc;   /* input time */

C++ Programming Assignment ATM Machine Phase 1 In this assignment you will create a program that allows a user to do the following: 1) Create a bank account by supplying a use

Molecular dynamics for a Lennard-Jones system (in C++) 1. Write a function which reads in the input variables of a molecular dynamics simulation of a Lennard-Jones system. The inpu

Each function has its own stack frame between %fp and %sp. Let Caller calls Callee. Then Caller's %sp becomes callee's %fp, and callee's %sp set to be a new value (a smaller one be

To develop a web crawler such that when given a base URL, it will traverse the entire web tree and then build an index of keywords and what URL link they appear on.   The web crawl

To implement a back account system for new users

Question 1 Explain the following Object Oriented Concepts with suitable examples for each Question 2 Explain the following Object Oriented Methodologies Question 3 Descr

Passing and Returning Objects Objects can be passed to a function and returned back just like normal variables. When an object is passed by content, the compiler makes another