- Dec 7, 2001
- 1,046
- 0
- 0
I'm currently taking a functional programming language course at college and can't wrap my head around how to solve the problem. I was wondering if someone can help point me in the right direction with pseudo-code or something.
Description: Using the built-in 'map' function in ML, the function is accepting a list of curried functions and needs to return a list with each function applied to X. The function needs to be a one line definition.
Here is what I have been working with, but can't seem to get it working properly:
I know this is not correct as it will only apply the first curried function in the list to x:
I need to do recursion on funList, but can't figure out how to go about doing it. Can someone please shed some light on how to go about doing this?
Description: Using the built-in 'map' function in ML, the function is accepting a list of curried functions and needs to return a list with each function applied to X. The function needs to be a one line definition.
Here is what I have been working with, but can't seem to get it working properly:
Code:
fun funApply funList x =
map (fn n => (hd funList) x) funList;
val funApply = fn : ('a -> 'b) list -> 'a -> 'b list
I know this is not correct as it will only apply the first curried function in the list to x:
Code:
- funApply [(fn z => z*z),(fn z => z),(fn z => z*z*z)] 5;
val it = [25,25,25] : int list
I need to do recursion on funList, but can't figure out how to go about doing it. Can someone please shed some light on how to go about doing this?