Question: assignment_repo_id=4265136&assignment_repo_type=AssignmentRepo) # Lab 3: Functions ## Task In this lab, you will use functions to create a simple unit converter. Most of the world uses
assignment_repo_id=4265136&assignment_repo_type=AssignmentRepo)
# Lab 3: Functions
## Task
In this lab, you will use functions to create a simple unit converter. Most of the world uses metric (or
SI) units of measurement such as kilograms, meters, and degrees Celsius. However, there are still a few
places that use US customary units such as pounds, feet, and degrees Fahrenheit. Our converter should be
able to convert between customary units and SI units.
- 1 *inch* is 25.4 millimeters. There are 12 inches in a *foot*. There are 3 feet in a *yard*. There are 1760 yards in a *mile*.
- 1 *ounce* is 28.349523125 grams. 1 ounce is 16 of a *pound*. There are 2000 pounds in a *short ton*.
Write unit conversion function using piping, composition and currying.
Warning: Do not change signatures of the provided function definitions!
## Test
Press **Run** button to execute and test your program.
- Or run `make test` command in the command line to verify the correctness of your program.
## Submission
- Commit & push all changes that to the corresponding assignment repository on GitHub, using the **Repl.it** interface - **Version control** tab.
- Make sure that you committed changes to following files:
- ...
- Submit the link of the assignment GitHub repository in the corresponding assignment submission the Blackboard.
- Open corresponding assignment on the Blackboard
- In **Assignment Submission** section, press **Write Submission** button
- Paste your assignment repository link in the **Text Submission** box
- Submit the assignment
### Before You Submit
You are required to test that your submission works properly before submission. Make sure that your program compiles without errors. Once you have verified that the submission is correct, you can submit your work.
### Coding Style
In any programming project, matching the existing coding style is important. Having different coding styles intermixed leads to confusion and bugs. Students are required to follow the particular existing coding style that maintains the indentation style in `.fs` and `.fsx` files using spaces, not tabs.
In particular, pay close attention to function declarations and how the function name begins the line after the function return type. For helper functions which are limited in scope to a specific file, you must declare the function as `static` in the same file in which it is used.
*Indentation*: The indentation style for your work have to be 4 spaces. Many students are taught to use tabs for indentation, which can make code very hard to read, especially when there are several levels of indentation.
For additional information, see [F# style guide](https://docs.microsoft.com/en-us/dotnet/fsharp/style-guide/) or [A comprehensive guide to F# Formatting Conventions](https://github.com/fsprojects/fantomas/blob/master/docs/FormattingConventions.md)
module Assignment
// DO NOT MODIFY LEFT PART OF `LET` OPERATOR
// Define following distance unit transformations
let inchToMillimeter v =
0.0 // write your code here
let footToInch x =
0.0 // write your code here
let yardToFoot v =
0.0 // write your code here
let mileToYard mile =
0.0 // write your code here
(*
Use ONLY above functions and the forward pipe operator, `|>`, to define the following unit transformation
Forward pipe operator passes the result of the left side to the function on the right side.
*)
let yardToMillimeter y =
0.0 // write your code here
// Define the curried function `divBy1000` that has the signature `float -> float -> float`
let divBy1000 =
fun x->x // write your code here
(*
Use ONLY above functions to define the following two functions. DO NOT CHANGE SIGNATURES!
*)
let millimeterToMeter n =
0.0 // write your code here
let meterToKilometer =
fun x->x // write your code here
(*
Use above functions and function composition operator, `>>`, to define the following unit transformations
Forward composition operator composes two functions into one.
*)
let millimeterToKilometer =
fun x->x // write your code here
let inchToMeter =
fun x->x // write your code here
let yardToKilometer =
fun x->x // write your code here
let mileToMeter =
fun x->x // write your code here
// Define following weight unit transformations
let ounceToGram v =
0.0 // write your code here
let poundToOunce p =
0.0 // write your code here
let shortTonToPound t =
0.0 // write your code here
(*
Use ONLY above functions to define the following two functions. DO NOT CHANGE SIGNATURES!
*)
let gramToKilogram g =
0.0 // write your code here
(*
Use ONLY above functions and function composition operator, `>>`, to define the following unit transformations
Forward composition operator composes two functions into one.
*)
let gramToMetricTon =
fun x->x // write your code here
let poundToKilogram =
fun x->x // write your code here
let shortTonToMetricTon =
fun x->x // write your code here
please write it in c#
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
