Write the necessary function in a tail-recursive manner

Assignment Help Programming Languages
Reference no: EM132257862

Programming Languages Assignment - four small F# functions

Overview - In this assignment, you're going to write 4 small functions, using both tail recursion and higher-order approaches. The exercise is setup on Codio, but you can work in whatever environment you prefer. Regardless of where you work, be sure to submit the 4 functions separately as described in the next section.

Exercises -

Exercise 1: subset S L

Login to Codio and edit the file "hw0901.fs". Read the comments:

NOTE: you can solve using tail-recursion, or using higher-order approach. Whatever you prefer. Beware that List.length is an O(N) operation, it actually traverses the list and counts the elements.

HINT: there are a variety of solutions. One idea is write a helper function "contains e L" that returns true if e is an element of L, and false if not. Then build on that to define subset. This leads to an O(N^2) solution, which is fine.

Write the required function, using whatever approach you prefer. To test your work, open a terminal window and load the file into F# interactive.

Exercise 2: delete e L in a tail-recursive manner

Edit the file "hw0902.fs". Read the comments, and write the necessary function in a tail-recursive manner. Test using F# interactive.

NOTE: write a tail-recursive version using a helper function; do not change the API of the original delete function. You'll also need to build the new list efficiently; you can use List.rev if need be.

Exercise 3: delete e L using a higher-order approach

Edit the file "hw0903.fs". Read the comments, and write the necessary function using a higher-order approach. Test using F# interactive.

Exercise 4: mergesort L

Edit the file "hw0904.fs". Read the comments, and rewrite the merge function to work in a safe, efficient manner (i.e. tail-recursive, and building the new list efficiently). Test using F# interactive.

Attachment:- Assignment Files.rar

Reference no: EM132257862

Questions Cloud

How did the quantitative and qualitative risk analyses help : How did the quantitative and qualitative risk analyses help you in prioritizing the project risks and assigning numerical values?
Explain the concept of color lightness spectrum : Kirk (2016) states that the topic of color can be a minefield. The judgement involved with selecting the right amount of color for a particular application.
What problem are you trying to solve : Who are you and why you're here? Keep it short and sweet. What problem are you trying to solve? Is it really a problem?
Discuss the critical business functions in brief : Describe in 500 words the disaster recovery plan and who is responsible at Finance place of employment. Consider the critical business functions.
Write the necessary function in a tail-recursive manner : CS 341 Programming Languages Assignment - four small F# functions. Write the necessary function in a tail-recursive manner. Test using F# interactive
Determine means to remove the causes of defects : Confirm the key variables and quantify their effects on the critical-to-quality characteristics (CTQs).
What are your thoughts on the limitations of the study : Appropriate use of both basic ANOVA and its more advanced versions depends on data meeting the assumptions associated with the test.
Identify the qualities of a change leader : Identify the qualities of a change leader. Also, explain how leaders can serve as role models for change.
Describe how externality of make new homeless : Externalities can have a significant positive or negative affect on a property's value. Describe how externality of make new homeless shelter in an area

Reviews

len2257862

3/15/2019 11:12:26 PM

Individual work only, late work not accepted. Submission: submit electronically on Gradescope. Grading and Electronic Submission - When you’re ready, submit your 4 source code files “hw0901.fs” .. “hw0904.fs” on Gradescope under “HW09”. Note: if you added additional code to the files for testing purposes, such as a main() function, you’ll need to comment out / delete that code before submitting.

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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