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
Define External Storage Class - computer programming? When a variable is declared outside a function the storage is permanently assigned to it and its storage class is 'extern'

Please use C or C++ to write your programs. Our homework will focus on SUN sparc machines because to exploit x86 stack-overflow is too easy. This is not just a programming assignme

Ask questioGiven an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. I

A: you can exploit by overloading standard operators on a class, the intuition of the users of that class. This allow users program in the language of the problem domain instead of

Write a C program to input three real numbers and  print them out as follows : The first variable is ....... and the second one is ...... The last variable is .......... T

You are to write a C++ program which will compute the gross pay, Social Security Tax, Income Tax and net pay for an employee. The program needs to prompt for and read the employ


can you help with the assignment, I don''t want to upload the assignment but want somebody to work with, do you do that?

Create an applet that bounces a blue ball inside an applet using Thread. The ball (diameter is 10) will start at position (0,0). When the ball hits the edge of the applet, the ba

Discuss the saleint featuresand application of c