[Haskell-cafe] Re: On the verge of ... giving up!

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Mon Oct 15 09:52:38 EDT 2007


On Oct 15, 2007, at 7:59 , Felipe Lessa wrote:

> On 10/15/07, apfelmus <apfelmus at quantentunnel.de> wrote:
>>    lasts :: Int -> [a] -> [a]
>>    lasts n xs = head $ [x | (x,[]) <- zip (tails xs) (tails $ drop  
>> n xs)]
(...)
>>    main n = print . sum . map read . lasts n . lines =<< getContents
>
> But that's a a two-liner now heh =).

.oO { if you want Perl, you know where to find it... }

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH




More information about the Haskell-Cafe mailing list