Skip to content

Instantly share code, notes, and snippets.

@qnikst
Created January 22, 2014 13:16
Show Gist options
  • Save qnikst/8558529 to your computer and use it in GitHub Desktop.
Save qnikst/8558529 to your computer and use it in GitHub Desktop.
import Criterion.Main
import System.Environment
import qualified Data.Vector.Unboxed as V
magicHere :: Int -> Int
magicHere n = V.sum (V.take n p1)
where
p1 = V.unfoldr (\(c,s) -> let k = c+s in k `seq` Just (k,(c+1,k))) (0,1)
helper n = magicHere n
main = do
n <- fmap (read . head) getArgs
print $ magicHere n
putStrLn "Happy Me!"
{-
defaultMain
[ bench "magic-here" $ nf helper n]
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment