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:

  http://thread.gmane.org/gmane.comp.lang.haskell.general/15007

Regards,
apfelmus

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to