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
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
Develop G-code generating software Project Description: I'm presently using Slicer on a polymer jetting 3d printer. The toolpaths were thought out for FDM printers and thus a

Requirements: 1.  This assignment as well as other assignments in this class must be finished on Windows operating system. 2.  Zip your program and submit the zip file on ANG

Define some features of static storage class in c program? The features of a variable defined to contain a static storage class are as follows. Storage - memory Default

Run the following C++ program with and without preprocessor variable POSTFIX defined. #include using namespace std; extern "C" int atoi( const char *str );

Explain string constants in c language - Escape Sequences? Illustrations are "945", "hello", "well done", "5+3". The character constant (example 'x') isn't equivalent to the st

Define Passing Structure to a Function? A structure is able to be passed as a function argument identical to any other variable. If we are merely interested in one member of a

Explain the Bit Wise Operations? C language in particular was created to make it easier to write operating systems. The objective was to have a language that provided excellent

Define Some Features of Automatic Variables in C program? The features of automatic variables are like as Storage - memory Default initial value - an unpredictable value,

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b