Question: USE OCaml language not in any other language Modify the following code to eliminate the words repeated by itself more than 3 times. let rec
USE OCaml language not in any other language
Modify the following code to eliminate the words repeated by itself more than 3 times.
let rec destutter list =
match list with
| [] -> []
| [hd] -> [hd] | hd1 :: hd2 :: tl ->
if hd1 = hd2 then destutter (hd2 :: tl)
else hd1 :: destutter (hd2 :: tl)
;;
#destutter ["hey";"hey";"hey";"man!"];;
Tthe output is
n!"];; - : string list = ["hey"; "man!"]
_____________________________________________
similarly modify the code if i give
#destutter ["hey";"hey";"hey";"man!"];;
the result will be
- : string list = ["hey"; "hey"; "man!"]
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
