I'm new to Haskell and I was wondering how would I be able to keep track of the index when it comes to higher order classes I'm trying to build a function that takes a [a] list and a function (a->Int->b) which essentially would be f(ai, i) and returns list [b].
I thought of doing something like:
higherOrd :: [a]->(a->Int->b)->[b] higherOrd t f = [f x y | x <- t, y <- [1..length(t)]] for example, if I do higherOrd (1,2..10) (+) I get:
[2,3,4,5,6,7,8,9,10,11,3,4,5,6,7,8,9,10,11,12,4,5,6,7,8,9,10,11,12,13,5,6,7,8,9,10,11,12,13,14,6,7,8,9,10,11,12,13,14,15,7,8,9,10,11,12,13,14,15,16,8,9,10,11,12,13,14,15,16,17,9,10,11,12,13,14,15,16,17,18,10,11,12,13,14,15,16,17,18,19,11,12,13,14,15,16,17,18,19,20] when I would want to get [2,4,6,8,10,12,14,16,18,20]