level: Writin functional
Questions and Answers List
level questions: Writin functional
Question | Answer |
---|---|
Write a function called fx that will take a as an argument and add 4 to it | fx a = a + 4 |
Write a function called f that will take the argument b and d and add them | f [b,d] = b + d |
f1 a = a + 3 f2 [a,b] = a + b f3[d,e] = f1 (f2 [d,e]) Calculate f3[2,1] | 6 |
What type of functions a map | Map is a higher order function |
Whats the map function do | Map applies a given function to each item in a list of values |
Given: fx a = a + 3 fu l = map fx l where l = [5,11,27,12] Wat would be the output? | 8,14,30,15 |
What does the filter function do | Use of a cinditional operator to returna new list |
Write a functin to return the items in a list greater than 4 Called fx With list e | fx e = filter (>4) e |
fw h = fold (*) 0 h This = wat? | 0 |
Write a funcion called gt that will add each item in the list p from 0 | gt p = fold (+) 0 p |