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
#include stdio.h> #include conio.h> #include string.h>   void del(char[],char *); main() {           char str[30],ch,*pp;           clrscr();           p

Problem: (a) A GUI can contain text-fields, buttons, and other labels. A button usually triggers an event on the GUI. Explain the different processes in registering an event

Scope Rules and Storage Classes The storage class verifies the life of a variable in terms of its duration or its scope. There are four storage classes : automatic static

Define a structure to store roll no, name and marks of a student. b) Using the structure of Q2. a), above write a ''C'' program to create a file "student.dat". There must be one r

Explain the  bit fields portable or not? - No, Bit fields aren't portable. - As Bit fields can't span machine words and number of bits in a machine word is different on diff

Ask queCreate an object oriented application with C# that computes the area of a rectangle, and the area and the volume of a cuboid. Based on the inheritance concept, create a bas

Multiple Inheritance Multiple inheritance , as the name suggests , is  deriving a class from more than one class . The derived class inherits all the properties of all its base c

How do one throw polymorphically?               A: Sometimes people write code such as: class MyExceptionBase { }; class MyExceptionDerived : public MyExceptionBase { };

To store a date use a structure that contains three members date, month and year. If the dates are equal then display message “Equal” otherwise “Unequal” Program structure: main()

What is the purpose of return values? Can you not return any values from a function? If you could what would he function look like?