# No instance for (RealFrac Int)

Version imprimable

• 06/06/2015, 16h08
vasilpapa
No instance for (RealFrac Int)
Bonjour,
Je n'arrive pas a terminer ce petit bout de code
Code:

```123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475import Data.Monoid import System.IO import System.Random import Graphics.Gloss   a = take 11250 (iterate ( \row -> zipWith (+) ([0] ++ row) (row ++ [0])) [1]) b :: [Int] b = concat a c = [0..150] :: [Float] d = [0..150] :: [Float] e = [(x, y) | x <- c, y <- d]   main = do affiche   affiche = display (InWindow "Pascal" (300, 300) (10, 10)) black (picture)   picture = pictures (listOfPoints n p coul) where n = 91200 p = 0 coul = 0   listOfPoints 0 _ _ = [] listOfPoints n p coul = point : listOfPoints (n-1) p' coul' where p' = calcp n p coul' = teinte n point = dessin n p' coul'     teinte n |(b !! n) < 128 = ((256`mod`(256 - 2*(b !! n)))`mod`13) |otherwise = 0   dessin n p' coul' |fst(e !! p') > snd(e !! p') = translate (0) (0) (color black (circle 0.0)) |n <= 11400 = translate (fst(e !! p')) (snd(e !! p')) (color (myColor (coul'))(circle 1.0)) |n <= 22800 = translate (-fst(e !! p')) (snd(e !! p')) (color (myColor (coul'))(circle 1.0)) |n <= 34200 = translate (fst(e !! p')) (-snd(e !! p')) (color (myColor (coul'))(circle 1.0)) |n <= 45600 = translate (-fst(e !! p')) (-snd(e !! p')) (color (myColor (coul'))(circle 1.0)) |n <= 57000 = translate (snd(e !! p')) (fst(e !! p')) (color (myColor (coul'))(circle 1.0)) |n <= 68400 = translate (-snd(e !! p')) (fst(e !! p')) (color (myColor (coul'))(circle 1.0)) |n <= 79800 = translate (snd(e !! p')) (-fst(e !! p')) (color (myColor (coul'))(circle 1.0)) |otherwise = translate (-snd(e !! p')) (-fst(e !! p')) (color (myColor (coul'))(circle 1.0))   calcp n p |n == 0 = 0 |n`mod`11400 == 0 = 0 |otherwise = p + 2   myColor coul' = ( [ca,cb,cc,cd,ce,cf,cg,ch,ci,cj,ck,cl,cm,cn,co,cp] !! abs(round(coul')) )   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```
Car j'ai le message :
Pascal1.hs:35:17:
No instance for (RealFrac Int) arising from a use of `dessin'
Possible fix: add an instance declaration for (RealFrac Int)
In the expression: dessin n p' coul'
In an equation for `point': point = dessin n p' coul'
In an equation for `listOfPoints':
listOfPoints n p coul
= point : listOfPoints (n - 1) p' coul'
where
p' = calcp n p
coul' = teinte n
point = dessin n p' coul'

La valeur de couleur doit absolument être déterminée selon la formule de teinte, si non pas de Pascal Carpet :
Pièce jointe 179852( une des images obtenues par VB6. )
Alors, au secours !
Ah, en ajoutant fromIntegral devant coul' dans le dessin ça marche. Le dessin n'est pas bon, je doit revoir mes equations, la liste actuelle correspond bien au triangle de Pascal, mais la fractale nécessité une liste obtenue par un algorithme différent.