Implement:
bool no_uniq(list_t l);
//E: Returns true if l has no elements that appear only once in l; returns false otherwise
//Ex1: (1,5,1,5,1) -> True
//Ex2: (1,5,1,1) -> False
Functions already implemented:
bool list_isEmpty(list_t list); //True if the list is empty, false otherwise
list_t list_make(); //Make an empty list
list_t list_make(int elt, list_t list); //Make a list with element elt followed by list
int list_first(list_t list); //Retrieve the first element of list
list_t list_rest(list_t list); //Retrieve all elements of list besides the first one
So I’m expected to be able to handle this problem tail-recursively, but I’m having a very hard time thinking about how I can translate the nested loops that I would normally have into a tail recursive function. I know that one tail recursive call should handle the “outer” loop, and one should handle the “inner” loop, but putting it all together to solve this problem seems almost impossible. Any help would be greatly appreciated.
Without seeing much of the code, I would say
If it is c as I suspect, you can change
const list_t&to justlist_t.