[Haskell-cafe] Re: Producing MinimumValue

apfelmus apfelmus at quantentunnel.de
Fri Jul 20 08:54:22 EDT 2007

Sebastian Sylvan wrote:
>> >minimumValue :: [Int] -> Int
>> >minimumValue ns = head (iSort ns)
>> If I were going to use a sort, then yes, that's the way I would do it.
>> Of course, sorting isn't the best way to solve the problem, as sorting
>> will always be at least O(n * log n), whereas a more straightforward
>> algorithm would be O(n).
> Actually, since Haskell is lazy and only the first element is required
> for minimumValue, the above algorithm should be O(n).

Just for reference:



More information about the Haskell-Cafe mailing list