Insoluble pour un débutant, j'ai tout essayé.
Voici le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
 
import Data.Monoid
import System.IO
import System.Random
import Graphics.Gloss
 
larg = 320
haut = 200
 
minX = fromIntegral -2.4
maxX = fromIntegral 2.4
minY = fromIntegral -1.5
maxY = fromIntegral 1.5
 
rc = [ (minX + (maxX - minX)`div`larg * x) | x <- [0,1..319]]
ic = [ (minY + (maxY - minY)`div`haut * y) | y <- [0,1..199]]
 
x = [0,1..319]
y = [0,1..199]
 
main = do
        let rz = 1
        let iz = 0
	affiche rz iz
	main
 
affiche rz iz = display  
	 (InWindow
	       "Simple Mandel" 	 -- window title
		(320, 200) 	 -- window size
		(10, 10)) 	 -- window position 20
         black                   -- background color
         (picture rz iz)     -- picture to display
 
picture rz iz = pictures (listOfPoints n rz iz r i temoin c l m)
   where
     n = 1920
     r = 0
     i = 0
     temoin = 0
     c = 1
     l = 0
     m = 0
listOfPoints 0 _ _ _ _ _ _ _ _ = []
listOfPoints n rz iz r i temoin c l m = point : listOfPoints (n-1) rz' iz' r' i' temoin' c' l' m' 
    where
	r' = rz
	i' = iz
	c' = comptec  c n
	l' = comptel l c
	rz' = r'*r' - i'*i' + (rc !! (l'))
	iz' = 2*r'*i' + (ic !! (c'))
	temoin' = (rz'*rz' + iz'*iz')
	m' = fixem temoin'
	point = choixp c' l' m'
 
fixem temoin'
	|temoin' > 4 = 5
	|temoin' <= 4 = 3
 
comptec c n
	|n`mod`200 <= 0 = c+1
	|n`mod`200 > 0 = c 
 
comptel l c
	|c`mod`200 <= 0 = l+1
	|c`mod`200 > 0 = l
 
choixp n c' l' m'
	|m' > 4 = translate (x !! (l')) (y !! (c')) (color (myColor(n/2)) (circle (1.0)))
	|m' <= 4 = translate (0) (0) (color red (circle (1.0)))
 
myColor n = ( [ca,cb,cc,cd,ce,cf,cg,ch,ci,cj,ck,cl,cm,cn,co,cp] !! (round(n/120)) )
 
ca = white
cb = light(light yellow)
cc = light yellow
cd = yellow   
ce = light(light orange)
cf = light orange
cg = orange
ch = light (dark orange)
ci = light red
cj = red
ck = dark red 
cl = light violet
cm = violet
cn = light(light (dark violet))
co = light ( dark violet)
cp = blue
Et voici le message :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
27
28
29
30
31
32
33
34
35
36
37
38
SimpleMandel.hs:34:27:
    Couldn't match type `a2 -> Picture' with `Picture'
    Expected type: [Picture]
      Actual type: [a2 -> Picture]
    In the return type of a call of `listOfPoints'
    In the first argument of `pictures', namely
      `(listOfPoints n rz iz r i temoin c l m)'
    In the expression: pictures (listOfPoints n rz iz r i temoin c l m)

SimpleMandel.hs:54:17:
    Could not deduce (RealFrac Int) arising from a use of `choixp'
    from the context (Integral a, Num a3, Ord a3)
      bound by the inferred type of
               listOfPoints :: (Integral a, Num a3, Ord a3) =>
                               a
                               -> (a1 -> b0)
                               -> (a1 -> b0)
                               -> (a1 -> b0)
                               -> (a1 -> b0)
                               -> (a1 -> b0)
                               -> Int
                               -> Int
                               -> Int
                               -> [a3 -> Picture]
      at SimpleMandel.hs:(43,1)-(54,31)
    Possible fix: add an instance declaration for (RealFrac Int)
    In the expression: choixp c' l' m'
    In an equation for `point': point = choixp c' l' m'
    In an equation for `listOfPoints':
        listOfPoints n rz iz r i temoin c l m
          = point : listOfPoints (n - 1) rz' iz' r' i' temoin' c' l' m'
          where
              r' = rz
              i' = iz
              c' = comptec c n
              l' = comptel l c
              ....
Comment faire ?