Last active
February 12, 2018 17:42
-
-
Save oisdk/7002c6df30e4bce74b7835892ed47203 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE RecursiveDo #-} | |
import qualified Data.Map.Strict as Map | |
import Control.Monad.State.Strict | |
repMax :: (Traversable t, Ord a) => t a -> t a | |
repMax xs = flip evalState Nothing $ mdo | |
ys <- forM xs $ \x -> do | |
modify (max (Just x)) | |
pure (max x res) | |
~(Just res) <- get | |
pure ys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment