Question: Please program these in ML so that it works and runs 1. Write ML expressions that do the following: 1. Defines a function printValue that
Please program these in ML so that it works and runs
1. Write ML expressions that do the following: 1. 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 2. Binds the value ("AAPL", 100, 5) to the variable appleStock 3. Calls the function printValue with the variable appleStock
2. Write ML expressions that do the following: 1. 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). 2. Binds the value ("IBM", 30, 10) to the variable ibmStock 3. Calls the function compareValue with appleStock and ibmStock as arguments
3. Write ML expressions that do the following: 1. 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). 2. Binds the value ("GOOG", 70, 15) to googleStock 3. Binds the value ("FB", 20, 8) to facebookStock 4. Creates a list of all four stock tuples (appleStock, ibmStock, googleStock and facebookStock) bound to stockList 5. Calls findMaxValue with stockList as its argument
4. Write ML expressions that do the following: 1. Defines findMaxMalueTwo, which uses compareValue as a nested function
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
