326925 (10) [Avatar] Offline
#1
How do you write a function that takes a function as an argument and a List and can be used to define both add3toAll and mul3byAll.
I got as far as this, then I am stuck.
add3toAll [] = []
add3toAll(xsmilies) = (3+x):add3toAll xs
g = add3toAll
mul3byAll [] = []
mul3byAll(xsmilies) = (3 * x):mul3byAll xs

h = mul3byAll


f = if (g [1,2,3,4] == add3toAll [1,2,3,4])
then g [1,2,3,4]
else
h [1,2,3,4]

Thanks for your help