[project @ 1998-04-30 20:38:38 by sof]
[ghc-hetmet.git] / ghc / tests / numeric / should_run / arith008.hs
1 --!!! a random test from Nick North
2 -- (got this in mid-1993; don't remember why.  WDP 95/02)
3 --
4
5 random_numbers :: (Int, Int, Int) -> [Float]
6 random_numbers (s1,s2,s3)
7     =  map (snd . properFraction . combine) (iterate f (s1,s2,s3))
8        where
9        combine :: (Int,Int,Int) -> Float
10        combine (a,b,c)  =
11             fromIntegral(a)/30269 + fromIntegral(b)/30307
12             + fromIntegral(c)/30323
13        f (a,b,c)  =
14            ((171*a) `mod` 30269, (172*b) `mod` 30307, (170*c) `mod` 30323)
15
16 -- partain: changed to cvt spaces into newlines (easier to see bugs)
17 -- sof: define approp. version of showList to do this.
18 main = putStr (showL (showsPrec 0) (take 1000 (random_numbers (9807, 65, 32975))) "\n")
19
20 showL showx []     = showString "[]"
21 showL showx (x:xs) = showChar '[' . showx x . showl xs
22   where
23     showl []     = showChar ']'
24     showl (x:xs) = showString ",\n" . showx x . showl xs