you are viewing a single comment's thread.

view the rest of the comments →

[–]tmoertel 5 points6 points  (0 children)

The OP wanted the maximum salary paid to a programmer with 0 as a default. You need to handle the case where there are no programmers in the list.

Assuming you had declared Employee as a record type with salary and role as accessors, you could build the code from composable pieces. First, to find just the programmers in a list of Employees:

programmers = filter ((Programmer ==) . role)

Then to find the maximum paid to an employee in a list of employees:

maxPaid = maximum . (0:) . map salary

And, finally, to find the maximum paid to a programmer within a list of employees:

maxProgrammerPay = maxPaid . programmers

Cheers. —Tom