bracketOnError, while, forever
ross at soi.city.ac.uk
Wed Feb 9 06:59:46 EST 2005
On Wed, Feb 09, 2005 at 11:50:48AM -0000, Simon Marlow wrote:
> On 08 February 2005 12:33, Thomas Jäger wrote:
> > First of all
> >> -- Cale Gibbard
> >> comparing :: (Ord a) => (b -> a) -> b -> b -> Ordering
> >> comparing p x y = compare (p x) (p y)
> > fits nicely with the ...By functions from Data.List.
> sortBy (comparing fst)
> is just too cute not to have. Any objections?
only that it's not clear where to put it.
This is useful when the function is expensive:
-- sortImage f = sortBy (comparing f)
sortImage :: Ord b => (a -> b) -> [a] -> [a]
sortImage f xs = map snd $ sortBy (comparing fst) [(f x, x) | x <- xs]
More information about the Libraries