Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

a) Complete the following function to return number of occurences of the first parameter in the second

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 t2 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) ))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

The provided image appears to contain two Haskell functions that are meant to count occurrences of a ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions