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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started