Write a function assoc_list: 'a list -> ('a* int) list that that takes a list as...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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)] 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)]
Expert Answer:
Answer rating: 100% (QA)
Execute Beautify Share Source Code let rec countelement element 1st match 1s... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
A crane boom of mass 450 kg with its center of mass at C is stabilized by two cables AQ and BQ (Ae = 304 mm2 for each cable) as shown in the figure. A load P = 20 kN is supported at point D. The...
-
Below is a table of comparative balances for 2022 and 2021 December 2022 December 2021 Accounts Receivable 35,000 45,000 Accounts Payable ...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
You accepted a new job with starting salary of $52,000 per year. The salary is expected to increase 4% each year. Now it is time to make a retirement plan for the next 39 years you expect to work....
-
Discuss five or more risks encountered in everyday life. How do you assess these risks? How do you treat these risks?
-
Highlands Company uses the weighted-average method in its process costing system. It processes wood pulp for various manufacturers of paper products. Data relating to tons of pulp processed during...
-
Develop the Weber number by starting with estimates for the inertia and surface tension forces.
-
Its probably safe to say that theres nothing more important in determining a bonds rating than the underlying financial condition and operating results of the company issuing the bond. Just as...
-
3. What is the certificate validation hierarchy? Show the validation process of a X509 certificate from the Root CA and a SubCA. (10 Points) ROOT CA SUB CA X509 Certificate 1 X509 Certificate 2
-
Which series has the highest beta. BraveNewCoin Liquid Index for Bitcoin 1D BNC Trading Brave Ne Yellow Green Blue Orange
-
How much energy does a pitcher transfer to a 0.15 kg baseball while throwing a 90 miles/hr fastball (40m/s)? You may assume air resistance to be negligible.
-
How do decision makers determine the receivables turnover based on the information reported by a company?
-
1 . A 1 . 1 - m - long spring with a spring constant of 6 2 N / m is hanging from the ceiling. It is initially in its equilibrium position. A 0 . 8 2 - kg mass is attached to the end of the spring...
-
Write a job advertisement for an External Auditor. Be sure to include the necessary skills and qualifications, duties and responsibilities for the auditor.
-
You purchase one Blue Bell Inc. September 120 put contract for a premium of $3.17. You hold the option until the expiration date when Blue Bell stock sells for $128.84 per share. Calculate gain/loss...
-
A firm has 10,000,000 shares of common stock outstanding, each with a market price of $15.00 per share. It has 80,000 bonds outstanding, each selling for $1020. The bonds mature in 15 years, have a...
-
Find the total capacitance of the combination of capacitors shown in the figure below. Number 0 UF 5.15 UF 3.55 UF HE 5.25 UF 3.25 UF 0.750 15.0 UF
-
The vapor pressure of the liquid NH, is measured at different temperatures. The following vapor pressure data are obtained. Temperature, K P, mmHg 217.1 223.4 234.7 588.1 Calculate the enthalpy of...
-
Rubin [Rub87] used the following example (rewritten here in C) to argue in favor of a goto statement: The intent of the code is to find the first all-zero row, if any, of an n n matrix. Do you find...
-
Using C++, Java, or C#, implement a Complex class in the spirit of Example 10.25. Discuss the time and space tradeoffs between maintaining all four values (x, y, , and ) in the state of the object,...
-
Rewrite the code of Figure 7.3 in Ada, Java, or C#. Figure 7.3: template class queue { item items [max_items]; int next_free, next_full, num_items; public: queue () : next_free (0), next_full(0),...
-
The following is the distribution of the hourly number of trucks arriving at a company's warehouse: Find the mean of this distribution, and using it (rounded to one decimal place) as the parameter...
-
With reference to Exercise 10.42, verify that the mean of the observed distribution is 1.6 , corresponding to \(40 \%\) of the cars requiring repairs. Then look up the probabilities for \(n=5\) and...
-
Among 100 purification filters used in an experiment, 46 had a service life of less than 20 hours, 19 had a service life of 20 or more but less than 40 hours, 17 had a service life of 40 or more but...
Study smarter with the SolutionInn App