Write a function to build a dictionary from two lists

Assignment Help Computer Engineering
Reference no: EM132112780

This is not Python ! It is OCAML FUNCTION PROGRAMMING LANGUAGE NEED CODE IN OCAML. Please help me this thank you!

Q1. Write a function to build a dictionary from two lists of equal length. One of the lists should contain elements that will serves as keys and the other list should contain elements that will serve as values.

Run your code to demonstrate that it works. Include the output in your answer. The output should show the two starting lists and the resulting dictionary.

What happens if the lists should chance to be of unequal length?

Q2. Now write a function that will do the inverse of the operation above i.e. this function takes a dictionary and returns two lists, one list containing keys and the other list containing values.

Can you really return two independent lists (i.e. can a function return two values)? How will you resolve this problem?

Run your code to demonstrate that it works. Include the output in your answer. The output should show the starting dictionary and the two resulting lists.

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_E4 (.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.

Reference no: EM132112780

Questions Cloud

Write a test program that creates an account object : Write a test program that creates an Account object with an account ID of 1122, a balance of $20,000, and an annual interest rate of 4.5%.
Showing the dominance of the classical perspective : In 1971 President Nixon said the era of big government is over showing the dominance of the Classical perspective. True/False
What does this equation really mean about optimizing : Globalization = Standardization + Localization: What does this equation really mean about optimizing a firm's offerings for maximum market penetration?
Write a program that gives simple math quizzes : Write a program that gives simple math quizzes. The program should display two random numbers that are to be added.
Write a function to build a dictionary from two lists : One of the lists should contain elements that will serves as keys and the other list should contain elements that will serve as values.
Prompt the user for two services from the menu : Prompt the user for two services from the menu. Output an invoice for the services selected. Output the cost for each service and the total cost.
Briefly explain hofstede''s five cultural dimensions : Briefly explain Hofstede's fi5e cultural dimensions. Be sure to give an example how these dimensions would manifest themselves in any two cultural (country) sce
Extract and analyse enterprise data : ITECH7406- Business Intelligence and Data Warehousing - ANALYTIC REPORT - business analytics project aimed at generating innovative analytics solutions
Write a program that keeps a dictionary : Write a program that keeps a dictionary in which both keys and values are strings - names of students and their course grades.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd