Skip to content
Browse files

tweaks

  • Loading branch information...
1 parent f0e71ed commit 2cbae14882423908a5b309ed22d9b4052929effa Evan Klitzke committed Apr 29, 2008
Showing with 4 additions and 3 deletions.
  1. +4 −3 14/ioarray.hs
View
7 14/ioarray.hs
@@ -1,3 +1,4 @@
+-- requires +RTS -K16M on my computer
module Main where
import Data.Array.IO
@@ -28,8 +29,8 @@ sndCmp :: Ord a => (b, a) -> (c, a) -> Ordering
sndCmp (a, b) (c, d) = compare b d
main :: IO ()
-main = do cache <- newArray (1, maxNum) 0 :: IO (IOUArray Int Int)
+main = do cache <- newArray (1, maxNum-1) 0 :: IO (IOUArray Int Int)
writeArray cache 1 1
- mapM (flip doCollatz $ cache) [1..maxNum-1]
+ mapM (flip doCollatz $ cache) [1 .. maxNum-1]
f <- unsafeFreeze cache :: IO (UArray Int Int)
- print $ fst $ maximumBy sndCmp (assocs f)
+ print $ fst $ maximumBy sndCmp $ assocs f

0 comments on commit 2cbae14

Please sign in to comment.
Something went wrong with that request. Please try again.