Equilibrium index: Difference between revisions

m
(→‎{{header|Wren}}: Library name change.)
Line 1,130:
=={{header|Haskell}}==
<lang haskell>import System.Random (randomRIO)
import Data.List (elemIndicesfindIndices, takeWhile)
import Control.Monad (replicateM)
import Control.Arrow ((&&&))
 
equilibr xs =
mapfindIndices (\(a, b) -> sum a == sum b) . takeWhile (not . null . snd) $
elemIndices True .
map (\(a, b) -> sum a == sum b) . takeWhile (not . null . snd) $
flip ((&&&) <$> take <*> (drop . pred)) xs <$> [1 ..]
 
Anonymous user