Question: perators like && and | | return strictly 0 or 1 values. Given two functions f 1 ( ) and f 2 ( ) which

perators like && and || return strictly 0 or 1 values.
Given two functions f1() and f2() which return a value of the same type, how would you implement the C equivalent of Scheme's (or (f1)(f2)). Can you package up your abstraction as a function? 15-points
A Java function takes a list of employees and returns a new list containing those employees having a particular gender:
ListEmployee select_gender(ListEmployee employees, Gender gender){ if (is_empty_list(employees)){ return new ListEmployee(); } else { Employee head = head_list(employees); ListEmployee tail = tail_list(employees); ListEmployee selectGenderRest = select_gender(tail, gender); return (head.gender == gender)? cons_list(head, selectGenderRest) : selectGenderRest; }}
Why is the above function not tail-recursive? 5-points
Rewrite it to be tail-recursive. It must be recursive and use the same original auxiliary functions. 10-points

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!