Area Under Curves and Volume of Revolving a Curve Discussions | Functional Programming | HackerRank

Area Under Curves and Volume of Revolving a Curve

  • + 0 comments

    Haskell concise solution solve :: Int -> Int -> [Int] -> [Int] -> [Double] solve l r as bs = [sum [(f as bs i) * dx|i<-range], sum [pi*(f as bs i)^^2 * dx|i<-range]] where dx = 0.001 fl = fromIntegral l fr = fromIntegral r range = [fl,fl+dx..fr] f as bs x = sum[(fromIntegral a)*(x^^b)|(a,b)<-zip as bs]