Question: #lang racket (struct cash (amount) #:transparent) (define appleStock (stock AAPL 100 5)) (valueOf appleStock) (valueOf myCash) (compareValue appleStock myCash) (compareValue myCash appleStock) (define investmentList (list

 #lang racket (struct cash (amount) #:transparent) (define appleStock (stock "AAPL" 100

#lang racket

(struct cash (amount) #:transparent)

(define appleStock (stock "AAPL" 100 5))

(valueOf appleStock) (valueOf myCash)

(compareValue appleStock myCash) (compareValue myCash appleStock)

(define investmentList (list appleStock googleStock facebookStock ibmStock myCash)) (findMaxValue investmentList)

(findMaxValue2 investmentList)

; Map function to all items in a list (define (map f xs) (if (null? xs) null (cons (f (car xs)) (map f (cdr xs)))))

(map valueOf investmentList)

; items in a list (define (filter f xs) (if (null? xs) null (if (f (car xs)) (cons (car xs) (filter f (cdr xs))) (filter f (cdr xs)))))

(filter moreThanTenShares investmentList)

(define (fold f acc xs) (if (null? xs) acc (fold f (f acc (car xs)) (cdr xs))))

1. Define a struct for stocks that has fields for symbol, price and number of shares 2. Create the stocks listed in the comments 3. Create a cash struct with name myCash and value of 200 4. Define a function valueOf that takes one investment as its argument 5. Define a function compareValue that takes two investments as arguments and returns true if the first argument is greater than the second, and false otherwise 6. Define a function indMaxValue that takes a list of investments and returns the investment with the greatest value. 7. Define a function findMaxValue2 that uses local bindings 8. Use filter to create a list of iust investments with more than ten shares 9. Use fold to calculate the total value of all the items in iovestmentlist 1. Define a struct for stocks that has fields for symbol, price and number of shares 2. Create the stocks listed in the comments 3. Create a cash struct with name myCash and value of 200 4. Define a function valueOf that takes one investment as its argument 5. Define a function compareValue that takes two investments as arguments and returns true if the first argument is greater than the second, and false otherwise 6. Define a function indMaxValue that takes a list of investments and returns the investment with the greatest value. 7. Define a function findMaxValue2 that uses local bindings 8. Use filter to create a list of iust investments with more than ten shares 9. Use fold to calculate the total value of all the items in iovestmentlist

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!