3 ms·
Just for fun, guard $ (a % k)^2 + (b % n)^2 + (d % xi)^2 + (e % pi)^2 + (et % mu)^2 + (i % s)^2 == 6 can be written as guard $ (6 ==) $
by wz1000 10y ago
Just for fun,
guard $ (a % k)^2 + (b % n)^2 + (d % xi)^2 +
(e % pi)^2 + (et % mu)^2 + (i % s)^2 == 6
can be written as
guard $ (6 ==) $
sum $ map (^2) $
zipWith (%)
[a ,b ,d ,e ,et,i ]
[k ,n ,xi,pi,mu,s ]
- conistonwater 10y agoAh! But should it be written like that?
- wz1000 10y agoI don't know. To me, sum $ map (^2) Is pretty clear as a sum of squares is a quite common mathematical idiom. The zipWith part could probably be avoided. guard $ (6 ==) $ sum $ map (^2) [(a%k),...]
- conistonwater 10y agoI think the original is still a lot cleaner, though.