Question
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
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