Skip to content

Instantly share code, notes, and snippets.

@mpickering
Created April 15, 2015 23:23
Show Gist options
  • Save mpickering/2b38e457f24c52d314c3 to your computer and use it in GitHub Desktop.
Save mpickering/2b38e457f24c52d314c3 to your computer and use it in GitHub Desktop.
RepMin for lists
module RepListMin where
repListMin :: [Int] -> [Int]
repListMin xs = res
where
(m, res) = repListMin' m xs
repListMin' :: Int -> [Int] -> (Int, [Int])
repListMin' m [x] = (x, [m])
repListMin' m (x:xs) = (newmin, m:ls)
where
(cmin, ls) = repListMin' m xs
newmin = min cmin x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment