[Shootout-list] haskell lists

Aaron Denney wnoise@ofb.net
Sun, 26 Sep 2004 13:00:35 -0600


--a8Wt8u1KmwUX3Y2C
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi.  Attached is a Haskell implementation of the "list processing" benchmark,
using the edison library included with GHC.

-- 
Aaron Denney
-><-

--a8Wt8u1KmwUX3Y2C
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="edison-lists.hs"

-- uses the edison library.
-- ghc -O2 -package data

module Main(main) where
import System(getArgs)
import qualified BankersQueue as L

copy = fmap id

test :: Int -> Int
test size | isok1 && isok2 = L.size l1'
          | otherwise = error "not OK"
                  where l1 = L.fromList [1..size] 
                        l2 = copy l1
                        l3 = L.foldl (L.snoc) L.empty l2
                        l2' = L.foldr (flip L.snoc) L.empty l3
                        l1' = L.reverse l1
                        isok1 = L.lhead l1' == size
                        isok2 = l1' == l2'
  
main = do ~[s] <- getArgs
          putStrLn . show . test . read $ s

--a8Wt8u1KmwUX3Y2C--