$24
This one is super easy because you have a final exam the day after this is due, there's no separate final exam week, and we’re just plain running out of time.
For each of the following problems, provide a pattern-matching solution in Erlang. Do not resort to just giving a new name to an existing Erlang function that already does what we want your function to do. Submit your solutions as a single file named "hw5.erl". Don't forget to declare the module name and the functions to be exported at the top of the file.
Grading will be on a 3-point scale for each solution (5 problems x 3 points maximum per solution = 15 points maximum).
And now, here are your last homework problems:
1) myremoveduplicates
myremoveduplicates("abacad") => "bcad" myremoveduplicates([3,2,1,3,2,2,1,1]) => [3,2,1]
2) myintersection
myintersection("abc", "bcd") => "bc" myintersection([3,4,2,1], [5,4,1,6,2]) => [4,2,1] myintersection([], [1,2,3]) => [] myintersection("abc", "") => ""
3) mylast
mylast("") => ""
mylast("b") => "b"
mylast("abcd") => "d"
mylast([1,2,3,4]) => [4]
mylast([]) => []
4) myreverse
myreverse("") => ""
myreverse("abc") => "cba"
myreverse([1,2,3]) => [3,2,1]
myreverse([]) => []
5) myreplaceall
myreplaceall(3,7,[7,0,7,1,7,2,7]) => [3,0,3,1,3,2,3] myreplaceall(3,9,[7,0,7,1,7,2,7]) => [7,0,7,1,7,2,7]