Question: Write a function assoc_list: 'a list -> ('a* int) list that that takes a list as input and returns a list of pairs where
Write a function assoc_list: 'a list -> ('a* int) list that that takes a list as input and returns a list of pairs where the first value of each pair is an element of the input list and the second integer of the pair is the number of occurrences of that element in the input list. This associative list should not contain duplicates. The order in the returned list does not matter. let assoc_list 1 = (* YOUR CODE HERE *) # assoc_list [1; 2; 2; 1; 3];; (int int) list = [(2, 2); (1, 2); (3, 1)] # assoc_list [true; false; false; true; false; false; false] ; ; : (bool int) list = [(false, 5); (true, 2)]
Step by Step Solution
There are 3 Steps involved in it
Execute Beautify Share Source Code let rec countelement element 1st match 1s... View full answer
Get step-by-step solutions from verified subject matter experts
