Question: This is Ocaml or function language Q1. Use pattern matching to write a function called power which takes as parameters the numbers x and n
This is Ocaml or function language
Q1. Use pattern matching to write a function called power which takes as parameters the numbers x and n and computes the value of x raised to the power n.
Run your code and demonstrate its results. Include the output in your answer.
Does your function handle negative numbers? Test it. Describe what happens and then provide an explanation for the reason for the results. Include the output in your answer.
Q2. Write a function called is member which take as parameters an item and a list. It returns true if the item exists with the list and false otherwise.
Run your code and demonstrate its results. Include the output in your answer. Which types of lists did you test?
Assignment Submission Instructions
Submit your work as two files:
A .ml or .caml code file (which must execute without warnings or errors)
A Microsoft Word document containing the contents of your code file (see further instructions below
Name your files as follows: YourFirstName_YourLastName_E3 (.ml or .caml, and .doc or .doctx)
In your code file, put your name, assignment name, and the date the assignment work must be submitted, at the top.
The questions and your explanations/reasoning must be included as comments in your code listing. The comments must:
Respond to any questions asked within the primary questions given above
Explain the functioning of the code segments you have written
Provide your reasoning for why you chose to write the code the way you did and if you considered any alternate ways of writing it
Make sure that the file is easily read i.e. it is nicely formatted with blank lines separating code segments, and comments appropriately associated with the relevant code segments, so that one can easily understand what you have written.
Copy your entire code listing and paste it into a Microsoft Word document. In the Microsoft Word document, change the comments text to green-colored font (your code text should be in black-colored font; this Word document too should be easily readable). See example below:
(* Comments here *)
Code statements here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
