Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You need to use Erlang language to solve following tasks: This question takes the example of fundraising through crowdfunding. Erlang Enterprises (EE) are trying to

You need to use Erlang language to solve following tasks:

This question takes the example of fundraising through crowdfunding. Erlang Enterprises (EE) are trying to raise a sum of money to support their further development. They ask for bids from people, which have the form {atom, int}, so that, joe bidding $1000 will be represented by the pair {joe,1000}. All the bids (in the order in which they arrived, earliest first) are given in a list, e.g.[ {joe,1000}, {robert,3000}, {grace,5000}, {ada, 500} ]We call this list the bid list.

(a) Bids should not be zero or negative. Write a function pos_bids which takes a bid list Bids and returns a list leaving out any bids that do not contain a positive number as the bid amount. (You may assume that all the bids do contain a number in the second place, and so you dont have to check for that.)

(b) Suppose that EE have set a threshold for the crowdfunding exercise, and that if the total of the bids is less than this amount then all should be returned to the bidders. Write a function success that takes Bids and Threshold as arguments and checks whether the sum of all the bid amounts in the list Bids is at least the value given in the Threshold parameter.

(c) Suppose that the list Bids does contain enough to exceed the Threshold, as checked in part (b). Write a function winners that takes Bids and Threshold as arguments, and returns the list of bids that have been successful. These will be taken from the front of the list until the Threshold is exceeded.

For example, if Bids is the list given at the start of the question, then the result of winners(5000, Bids) will be the list [ {joe,1000}, {robert,3000}, {grace,1000} ]

Note here that graces bid has been lowered to make the total precisely the threshold value, which is 5000 here.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

More Books

Students also viewed these Databases questions

Question

4. Similarity (representativeness).

Answered: 1 week ago