a) Complete the following function to return number of occurences of the first parameter in the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
a) Complete the following function to return number of occurences of the first parameter in the second parameter list. occurs 1 [1,2,3,1,2] will return 2 since 1 has 2 occurrences in the list. occurs 3 [1,2,3,1,2] will return 1 and occurs 4 [1,2,3,1,2] will return 0. occurs [] = 0 occurs a (x:xs) = let rest occurs a xs in if a==x then b) Complete the following function to return number of occurences of the first parameter in the nodes of the second parameter tree. The definition of tree is given below. In the sample tree t the calls return the corresponding values: occurst 1 t6 occurst 2 t→2 occurst 3 t1 occurst 4 t-0 else data Tree a = Node (a, Tree a, Tree a) | Empty deriving Show occurst Empty = 0 - occurst a (Node (x, left, right)) t = Node (3, Node Node = (2, Node (1, Empty, Empty), Node (1, Empty, Empty)), (1, Node (2, Node (1, Empty, Empty), Node (1, Empty, Empty)), Node (1, Empty, Empty) )) a) Complete the following function to return number of occurences of the first parameter in the second parameter list. occurs 1 [1,2,3,1,2] will return 2 since 1 has 2 occurrences in the list. occurs 3 [1,2,3,1,2] will return 1 and occurs 4 [1,2,3,1,2] will return 0. occurs [] = 0 occurs a (x:xs) = let rest occurs a xs in if a==x then b) Complete the following function to return number of occurences of the first parameter in the nodes of the second parameter tree. The definition of tree is given below. In the sample tree t the calls return the corresponding values: occurst 1 t6 occurst 2 t→2 occurst 3 t1 occurst 4 t-0 else data Tree a = Node (a, Tree a, Tree a) | Empty deriving Show occurst Empty = 0 - occurst a (Node (x, left, right)) t = Node (3, Node Node = (2, Node (1, Empty, Empty), Node (1, Empty, Empty)), (1, Node (2, Node (1, Empty, Empty), Node (1, Empty, Empty)), Node (1, Empty, Empty) ))
Expert Answer:
Answer rating: 100% (QA)
The provided image appears to contain two Haskell functions that are meant to count occurrences of a ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
On successful completion of MBA, you have joined a human resource consultant firm. You have been asked to prepare the job descriptions for the following category of organizations (Job titles...
-
a. Example 13-1: Batch Reactor with an Exothermic Reaction Wolfram 1. Adiabatic Case: Use Wolfram to see whether you can find a trajectory that is ready to ignite and whose trajectory looks like a...
-
Use the Journal of Accountancy website to research current trends in accounting. This website contains current trends in the various areas of accounting. Locate one article under the category of your...
-
The following items are dropped from an airplane. Rank them in order from lowest terminal speed to highest and justify your ranking. (a) Bowling ball (b) Beach ball (c) Spear or javelin (pointing...
-
Jenkins Frames Company, which manufactures ornate frames for original art work, began operations in January 2018. Bruce Preston, the owner, asks for your assistance. He believes that he needs to...
-
A publishing company sells 50,000 copies of a certain book each year. It costs the company $1 to store a book for one year. Each time that it prints additional copies, it costs the company $1,000 to...
-
How to prepare a deposition summary in different ways?
-
Mulcahey Builders (MB) remodels office buildings in low-income urban areas that are undergoing economic revitalization. MB typically accepts a 25% down payment when they complete a job and a note,...
-
What is the process of identifying activities in an organization and assigning costs under the Activity Based Costing ( ABC ) system? Elucidate. You will need to include the right numerical examples...
-
The financial statements for Harridges Ltd are given below for the two years ended 30 June 2009 and 2010. Harridges Limited operates a department store in the centre of a small town. Dividends were...
-
(1 point) Jason owes $59000 due at the end of 3 years with interest at j4 = 3%. In order to payoff the loan Jason decides to make deposits in a fund that earns J4 12.5%. The first deposit is $10000...
-
You purchase a stock for $20.00 on Monday morning. At the end of the day, the stock has traded up 5%. What is the new price of the stock
-
What is your company stock's intrinsic value using each of the four models? Constant Growth Model Multi-Stage Growth Model Discounted Dividend Model Market Multiples Approach Reconcile your company...
-
Bank failures in 2023 such as Silicon and Signature banks were most likely due to ineffective risk management. According to the U.S. Government Accountability Office both of these banks took on a...
-
= Let G=(V, E) be a connected undirected graph, and for every edge e E, let c(e) be its cost. Edge costs do not need to be positive. We say that H (U, F) is a subgraph of G if U CV, FCUXU, and FC E....
-
A one-year Treasury bill currently offers a 5% rate of return. A two-year Treasury note offers a 5.5% rate of return. Under the expectations theory, what rate of return do investors expect a one-year...
-
180. Amiodarone is the preferred anti-arrythmic drug in emergency management of tachyarrythmia. Identify the FALSE statement about Amiodarone a. Amiodarone is a Potassium channel blocker - Class III...
-
The cash records of Holly Company show the following four situations. 1. The June 30 bank reconciliation indicated that deposits in transit total $720. During July, the general ledger account Cash...
-
Sherry rents her vacation home for 6 months and lives in it for 6 months during the year. Her gross rental income during the year is $4,000. Total real estate taxes for the home are $950, and...
-
Carl and Jenny adopt a Russian orphan. The adoption takes 2 years and two trips to Russia and is final in 2012. They pay $6,000 in 2011 and $7,500 in 2012 of qualified adoption expenses, and have AGI...
-
Charlie's Green Lawn Care is a cash basis taxpayer. Charlie Adame, the sole proprietor, is considering delaying some of his December 2012 customer billings for lawn care into the next year. In...
-
The pendulum has a mass of \(7.5 \mathrm{~kg}\) with center of mass at \(G\) and has a radius of gyration about the pivot \(O\) of \(295 \mathrm{~mm}\). If the pendulum is released from rest at...
-
A metal hoop with a radius \(r=6\) in. is released from rest on the \(20^{\circ}\) incline. If the coefficients of static and kinetic friction are \(\mu_{s}=0.15\) and \(\mu_{k}=0.12\), determine the...
-
The \(\operatorname{drum} A\) is given a constant angular acceleration \(\alpha_{0}\) of \(3 \mathrm{rad} / \mathrm{s}^{2}\) and causes the 70-kg spool \(B\) to roll on the horizontal surface by...
Study smarter with the SolutionInn App