I wrote a function that takes a list and a number and returns a sum of shifted inverses:
sumInvZ::[Float]->Float->Float
sumInvZ zList z = let invList = [if z==x then 0 else 1/(z-x)|x<-zList] in foldr (+) 0 invList
I want to generalize this function to act on complex numbers as well. A simple solution is just to re-write it:
import Data.Complex
sumInvZC::[Complex Float]->Complex Float->Complex Float
sumInvZC zList z = let invList = [if z==x then 0 else 1/(z-x)|x<-zList] in foldr (+) 0 invList
But I'm also interested in making uses of the Complex monad to directly lift my SumInvZ. I've played around variations of liftM, but I've been unable to find a way to make it work. Is there a possibility?