Engineering
Engineering, 15.02.2020 05:24, sweatsierra

Suppose you are implementing a relational employee database, where the database is a list of tuples formed by the names, the phone numbers and the salaries of the employees. For example, a sample database may consist of the following list of tuples:

[("John", "x3456", 50.1) ; ("Jane", "x1234", 107.3) ; ("Joan", "unlisted", 12.7)]
Note that I have written parentheses around the tuples to make them more readable, but the precedences of different operators in OCaml make this unnecessary.

Define a function

find_salary : ((string * string * float) list) -> string -> float
that takes as input a list representing the database and the name of an employee and returns his/her corresponding salary. Think also of some graceful way to deal with the situation where the database does not contain an entry for that particular name, explain it, and implement this in your code.

Define a function

find_phno : ((string * string * float) list) -> string -> string
that is like find_salary, except that it returns the phone number instead.

What I have so far:

let rec find_salary li nm =
let rec helper name s =
match li with
| [] -> 0.0
| (n, p, s) :: t -> if (name = n) then s
else
helper t name

answer
Answers: 1

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:10, meganwintergirl
Afour cylinder four-stroke in-line engine has a stroke of 160mm, connecting rod length of 150mm, a reciprocating mass of 3kg and its firing order is 1-3-4-2. the spacing between cylinders is 100mm. i. show that the engine is in balance with regard to the primary inertia forces and primary 3. a and secondary inertia couples. li determine the out of balance secondary inertia force ii. propose ways of balancing this out of balance force and discuss the challenges that will arise
Answers: 3
image
Engineering, 04.07.2019 18:10, lowkeyqueenk
Apipe with an outside diameter of 15 cm is exposed to an ambient air and surrounding temperature of -20°c. the pipe has an outer surface temperature of 65°c and an emissivity of 0.85. if the rate of heat loss from the pipe surface is 0.95 kw per meter of length, the external convective heat transfer coefficient (h) is: (a) 12.5 w/m"k (b) 18.6 w/mk (c) 23.7 w/mk (d) 27.9 w/mk (e) 33.5 w/mk
Answers: 1
image
Engineering, 04.07.2019 18:10, wirchakethan23
Hydraulic fluid with a sg. of 0.78 is flowing through a 1.5 in. i. d. pipe at 58 gal/min. the fluid has an absolute viscosity of 11.8 x 105 lbf-sec/ft2. is the flow laminar, turbulent or within the critical range? give both a numerical reynolds number and a term answer.
Answers: 3
image
Engineering, 04.07.2019 19:10, Calliedevore
The proportional limit is always greater than the yield strength for a material. a)-trune b)- false
Answers: 3
Do you know the correct answer?
Suppose you are implementing a relational employee database, where the database is a list of tuples...

Questions in other subjects:

Konu
Chemistry, 03.07.2019 13:00
Konu
Mathematics, 03.07.2019 13:00