subject
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

ansver
Answers: 1

Another question on Engineering

question
Engineering, 04.07.2019 18:10
Coiled springs ought to be very strong and stiff. si3n4 is a strong, stiff material. would you select this material for a spring? explain.
Answers: 2
question
Engineering, 04.07.2019 18:10
Condition monitoring is a major component of. (clo4) a)- predictive maintenance. b)-preventive maintenance c)-proactive maintenance d)-reactive maintenance.
Answers: 1
question
Engineering, 04.07.2019 18:20
Have a greater impact on maintenance productivity than any other support group. (clo5) a)-the top management b)-inventory and purchasing c)-sub-contracting d)-cmms
Answers: 2
question
Engineering, 04.07.2019 19:20
Amass-spring-viscous damper system of mass 3 kg has a frequency of 100 rad/s and is critically damped. its initial conditions are x(0)-3 mm and (0)-2.3 m/s. does the system overshoot its equilibrium position? prove your answer
Answers: 1
You know the right answer?
Suppose you are implementing a relational employee database, where the database is a list of tuples...
Questions
question
English, 16.10.2021 01:00
question
Mathematics, 16.10.2021 01:00
question
Mathematics, 16.10.2021 01:00
question
Mathematics, 16.10.2021 01:00
question
History, 16.10.2021 01:00
Questions on the website: 13722367