summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-regress/perf/should_run/T149_B.hs
blob: fcc87cdf55cc91a466ab3d071f86e6c9447b5559 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Main (main) where

-- See Trac #149

-- Curently (with GHC 7.0) the CSE works, just,
-- but it's delicate.


import System.CPUTime

main :: IO ()
main = print $ playerMostOccur2 [1..m]

m :: Int
m = 22

playerMostOccur2 :: [Int] -> Int
playerMostOccur2 [a] = a
playerMostOccur2 (x:xs)
 | numOccur x (x:xs) > numOccur pmo xs = x
 | otherwise = pmo
    where pmo = playerMostOccur2 xs

numOccur :: Int -> [Int] -> Int
numOccur i is = length $ filter (i ==) is