CS 683 Emerging Technologies
Fall Semester, 2008
Assignment 1
© 2008, All Rights Reserved, SDSU & Roger Whitney
San Diego State University -- This page last updated 9/4/08
Due Sept 16 in class.
Write Erlang function(s) that given a string and a pattern and uses the pattern to split the string. It returns a list of two substrings. The first substring is the part of the string before the first occurrence of the pattern in the string. The second substring is the part of the string after the first occurrence of the pattern in the string. So if the pattern is "ab" and the string is "acabcabts" the code will return ["ac", "cabts"]. If the pattern is "bc" and the string is "bcad" the code returns ["", ad]. If the pattern is "ac" and the string is "bcad" the code will return ["bcad", ""]. Do not use regular expressions to solve this problem.
Using the results of the previous problem write erlang code that inputs a string and a pattern and splits the string at all occurrences of the pattern. So if the pattern is "ab" and the string is "acabcabts" the code will return ["ac", "c", "ts"].
Write erlang functions/code that given a file name that contains html and an html tag returns a list of all content of the given tags in the html in the order they appear in the file. Assume that the tags do not have attributes and the html is well-formed. Throw an exception if the file is empty. Do not use regular expressions to solve this problem. So if the file contained:
<html><body><h1>hi</h1>how are <h1>you</h1><h1>today?</h2></body></html>
If the tag is body the returned list would be ["<h1>hi</h1>how are <h1>you</h1><h1>today?</h2>"]
If the tag is h1 the returned list would be ["hi", "you", "today?"].
If the tag is h3 the returned list would be [].
Create N processes in a ring. Send a message round the ring M times. How long does it take for the message to go around the ring M times?