Today a student came to me with a piece of code that worked it executed
by itself, but produced different result in the context of his larger
problem. We cut down the example to the following:
> import Graphics.UI.Gtk
> -- should produce [(26471,0,65535),...
> rgbliste =
> (map (\ i ->
> let rb = 5 * (mod (mod 181935629 (4534+i)) 100)-250+128 in
> let gb = 5 * (mod (mod 128872693 (5148+i)) 100)-250+128 in
> let bb = 5 * (mod (mod 140302469 (7578+i)) 100)-250+128 in
> let r = min 255 $ max 0 rb in
> let g = min 255 $ max 0 gb in
> let b = min 255 $ max 0 bb in
> (r*257,g*257,b*257)) [0..])
> --farbliste = map (\ (r,g,b) -> Color r g b) rgbliste
> main :: IO ()
> main = do
> print $ head rgbliste
If you run it, it prints (26471,0,65535).
If you uncomment the def. of farbliste, it prints (44461,65535,65535).
I was surprised. What is going on?
Andreas Abel <>< Du bist der geliebte Mensch.
Theoretical Computer Science, University of Munich
Oettingenstr. 67, D-80538 Munich, GERMANY