Question: 1. Write ML expressions that do the following: a. Defines a function printValue that takes a tuple consisting of symbol, price and shares as arguments

1. Write ML expressions that do the following:

a. Defines a function printValue that takes a tuple consisting of symbol, price and shares as arguments and prints out the stock symbol and the value of price x shares b. Binds the value ("AAPL", 100, 5) to the variable appleStock c. Calls the function printValue with the variable appleStock

2. Write ML expressions that do the following: a. Defines a function compareValue that takes two tuples consisting of symbol, price and shares as arguments and returns the symbol for the stock with the greater value (price x shares). b. Binds the value ("IBM", 30, 10) to the variable ibmStock c. Calls the function compareValue with appleStock and ibmStock as arguments

3. Write ML expressions that do the following: a. Defines a function findMaxValue that takes a list of stock tuples consisting of symbol, price and shares as arguments and returns the symbol of the stock with the greatest value (price x shares). b. Binds the value ("GOOG", 70, 15) to googleStock c. Binds the value ("FB", 20, 8) to facebookStock d. Creates a list of all four stock tuples (appleStock, ibmStock, googleStock and facebookStock) bound to stockList e. Calls findMaxValue with stockList as its argument

4. Write ML expressions that do the following: a. Defines findMaxMalueTwo, which uses compareValue as a nested function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!