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

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

1 Expert Approved Answer
Step: 1 Unlock

Execute Beautify Share Source Code let rec countelement element 1st match 1s... View full answer

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!