$30
ECS 140A
Homework Assignment #5
This one is super easy because we’re 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".
Grading will be on a 5-point scale for each solution (4 problems x 5 points maximum
per solution = 20 points maximum).
And now, here are your homework problems:
1) myremoveduplicates
myremoveduplicates("abacad") = "bcad"
myremoveduplicates([3,2,1,3,2,2,1,1]) = [3,2,1]
2) mylast
mylast("") = ""
mylast("b") = "b"
mylast("abcd") = "d"
mylast([1,2,3,4]) = [4]
mylast([]) = []
3) myreverse
myreverse("") = ""
myreverse("abc") = "cba"
myreverse([1,2,3]) = [3,2,1]
myreverse([]) = []
4) 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]