Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Map fun map (f,xs) = case xs of [] => [] | x::xs => (f x)::(map(f,xs)) Filter fun filter (f,xs) = case xs of []

Map

fun map (f,xs) =

case xs of [] => [] | x::xs => (f x)::(map(f,xs))

Filter

fun filter (f,xs) =

case xs of

[] => []

| x::xs => if f x

then x::(filter (f,xs))

else filter (f,xs)

Reduce/Fold

fun fold (f,acc,xs) = case xs of [] => acc | x::xs => fold (f, f(acc,x), xs)

Zip

fun zip xs ys =

case (xs,ys) of

([],[]) => []

| (x::xs,y::ys) => (x,y) :: (zip xs ys)

1. Complete the symbols function, which returns a list of symbols from a list of stocks. Then complete symbols_map, which uses the map function to accomplish the same thing.

2. Complete the values function, which returns a list of values from a list of stocks. Then complete values_map, which uses the map function to accomplish the same thing.

3. Complete the greater_than_1000 function, which returns a list of stocks with values greater than 1000 from a list of stocks

4. Complete the symbols_and_values function, which returns the symbols and values of all stocks with values greater than 1000

5. Complete the total_value function, which returns total value of all stocks with values greater than 1000

mapreduce1.sml

mapreduce2.sml

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

=+Where do you want to live and work?

Answered: 1 week ago

Question

=+1 Where are the best places in the world to live (and work)?

Answered: 1 week ago

Question

=+Are you interested in working on global teams?

Answered: 1 week ago