[Shootout-list] GHC harmonic series (alpha)

Greg Buchholz sleepingsquirrel@member.fsf.org
Sat, 1 Jan 2005 17:40:00 -0800 (PST)


--0-1039850542-1104630000=:40440
Content-Type: text/plain; charset=us-ascii
Content-Id: 
Content-Disposition: inline

  See attached for a Haskell version of the harmonic series test.

Greg Buchholz




		
__________________________________ 
Do you Yahoo!? 
Take Yahoo! Mail with you! Get it on your mobile phone. 
http://mobile.yahoo.com/maildemo 
--0-1039850542-1104630000=:40440
Content-Type: text/x-haskell; name="harmonic.hs"
Content-Description: harmonic.hs
Content-Disposition: inline; filename="harmonic.hs"

-- sum harmonic series
-- comiple with:  ghc -O2 -o harmonic harmonic.hs

import System(getArgs)

main = do   [n] <- getArgs
            print $ foldl (\x y -> 1/y+x) 0 [1..(read n)]

--0-1039850542-1104630000=:40440--