[Haskell-cafe] Re: wanted: haskell one-liners (in the perl sense of one-liners)

Jules Bean jules at jellybean.co.uk
Tue Mar 20 08:54:22 EDT 2007


Thomas Hartman wrote:
> To answer my own post, the Data.List.sort *is* necessary.
>
> Otherwise, you get alphabetic sort.

Which is why you do the Set trick at a different stage in the process, 
like this:


>>
>> interact $
>> unlines
>> . map show
>>
>> -- more efficient than -- reverse . take 10 . reverse
>> . ( \s -> drop (length s - 10 ) s )
>> . Data.Set.toAscList . Data.Set.fromList --  move it *here* after 
>> integer conversion and it sorts and nubs for you
>> . map ( read :: String -> Integer )
>> . filter ( all Data.Char.isDigit ) . lines'



More information about the Haskell-Cafe mailing list