Please finish this problem in OCaml. Please implement two functions: string_explode : string -> char list string_implode : char list -> string string_explode turns a string into a list of characters and string_implode turns a list of characters back into a string. To implement these two functions, use a selection of the following higher-order functions: List.map, List.fold_right, List.fold_left and tabulate. tabulate is implemented for you in the prelude. You may also find the following functions from the OCaml string and char libraries useful: String.get : string -> int -> char returns the character at index n in string s. String.length : string -> int returns the length (number of characters) of the given string. Char.escaped : char -> string returns the string representation of the given character In order to get full marks for each question, you must use higher-order functions. Solutions using manual recursion will be capped at half marks. Please follow the follwing format: let string_explode (s : string) : char list =   raise NotImplemented let string_implode (l : char list) : string =   raise NotImplemented tabulate is defined as follow:  let rec tabulate f n =     let rec tab n acc =         if n < 0 then acc         else tab (n - 1) ((f n) :: acc)     in     tab (n - 1) []

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please finish this problem in OCaml.

Please implement two functions:

string_explode : string -> char list

string_implode : char list -> string

string_explode turns a string into a list of characters and string_implode turns a list of characters back into a string.

To implement these two functions, use a selection of the following higher-order functions: List.map, List.fold_right, List.fold_left and tabulate. tabulate is implemented for you in the prelude.

You may also find the following functions from the OCaml string and char libraries useful:

String.get : string -> int -> char returns the character at index n in string s.

String.length : string -> int returns the length (number of characters) of the given string.

Char.escaped : char -> string returns the string representation of the given character

In order to get full marks for each question, you must use higher-order functions. Solutions using manual recursion will be capped at half marks.

Please follow the follwing format:

let string_explode (s : string) : char list =
  raise NotImplemented

let string_implode (l : char list) : string =
  raise NotImplemented

tabulate is defined as follow: 

let rec tabulate f n =

    let rec tab n acc =

        if n < 0 then acc

        else tab (n - 1) ((f n) :: acc)

    in

    tab (n - 1) []

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Linked List Representation
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education