Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ocaml programing with obvious comments. 1. increment : int list -> int list adds one to each element in the list (increment [1;2;3] = [2;3;4])

Ocaml programing with obvious comments.

1. increment : int list -> int list adds one to each element in the list (increment [1;2;3] = [2;3;4])

2. lengths : 'a list list -> int list gives the length of each list in the list (lengths [[];[1;2;3]] = [0;3])

3. times_list : int -> int list -> int list multiplies the given number to each element in the list (times_list 3 [2;3;4] = [6;9;12])

4. product : int list -> int gives the product of all elements in the list; returns 1 for empty lists (product [1;2;3] = 6)

5. print_it : string list -> () prints each element in the list followed by " it" and a new line. (print_it ["work";"make";"do"] = (); but prints the three lines: 'work it', 'make it', and 'do it')

6. intercalate : string -> string list -> string first argument stands for a separator, gives a string of all the list elements separated by the separator, ignoring empty strings. Empty lists give the empty string. (intercalate ", " ["hello";"";"";"world";"!"] = "hello, world, !")

7. nonempty : 'a list list -> 'a list list returns all nonempty lists in the same order. (nonempty [[];[1;2;3]] = [[1;2;3]])

8. odds : int list -> int list returns all odd numbers in the input list. (odds [3;4;5;6;6;5;4;3;2] = [3;5;5;3])

9. skip_skips : string list -> string list returns all strings except the ones that read "skip" (skip_skips ["hello";"skip";"world";"!";"don't skip this!"] = ["hello";"world";"!";"don't skip this!"]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

How can inventory be controlled?

Answered: 1 week ago

Question

=+(16.32) 81(w) for w A and 0 Answered: 1 week ago

Answered: 1 week ago