Reputation: 45295
Here is my code:
data Polindrom = Polindrom { a :: Integer,
b :: Integer,
c :: Integer } deriving (Show)
euler_4 = [ p | y <- [10..20],
z <- [10..20],
let x = y * z,
let p = Polindrom { a = y, b = z, c = x },
let s = show x,
s == reverse s]
Now I need to find the element of euler_4 which have max 'c'. In Ruby I have used such construction:
}.sort { |a, b|
b[2] <=> a[2]
}[0]
How can I get it in Haskell?
Upvotes: 1
Views: 150
Reputation: 14291
A third possibility is Data.Ord.comparing
:
maximumBy (comparing c)
Upvotes: 1