Question: Haskell assignment (no imports, no help functions) M is a language which consists of strings with at least 3 instances of the string ab. Example:
Haskell assignment (no imports, no help functions)
"M" is a language which consists of strings with at least 3 instances of the string "ab".
Example:
ababab, ccbabbadeabcaaabab, abcabdabe is a part of M
abaaba, abadb, aaabbb, abab abab is not a part of M
Make a function trans :: String -> Int -> String with no help functions or data structure ( no AST and so on).
By calling trans s n:
1. Return a string which states "WRONG!", if s is not a part of M
2. If s is a part of M, return s with each instance of "ab" replaced by the number - which indicates the occurence of "ab" in s.
example:
trans "abcabbdbab" 1 = "1c2bdb3"
trans "ccbabbadeabcaaabab" 3 = "ccb3bade4caa56"
trans "abcab" 1 = WRONG!
trans "a2ababab" 1 = WRONG!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
