CONNEXION
  • RetourJeux
    • Sorties
    • Hit Parade
    • Les + populaires
    • Les + attendus
    • Soluces
    • Tous les Jeux
    • Gaming
  • RetourActu Gaming
    • News
    • Astuces
    • Tests
    • Previews
    • Toute l'actu gaming
  • RetourBons plans
    • Bons plans
    • Bons plans Smartphone
    • Bons plans Hardware
    • Bons plans Image et Son
    • Bons plans Amazon
    • Bons plans Cdiscount
    • Bons plans Decathlon
    • Bons plans Fnac
    • Tous les Bons plans
  • RetourJVTech
    • Actus High-Tech
    • Intelligence Artificielle
    • Smartphones
    • Mobilité urbaine
    • Hardware
    • Image et son
    • Tutoriels
    • Tests produits High-Tech
    • Guides d'achat High-Tech
    • JVTech
  • RetourCulture
    • Actus Culture
    • Culture
  • RetourVidéos
    • A la une
    • Gaming Live
    • Vidéos Tests
    • Vidéos Previews
    • Gameplay
    • Trailers
    • Chroniques
    • Replay Web TV
    • Toutes les vidéos
  • RetourForums
    • Hardware PC
    • PS5
    • Switch 2
    • Xbox Series
    • Switch
    • Pokemon pocket
    • FC 25 Ultimate Team
    • League of Legends
    • Tous les Forums
  • PC
  • PS5
  • Xbox Series
  • Switch 2
  • PS4
  • One
  • Switch
  • iOS
  • Android
  • MMO
  • RPG
  • FPS
En ce moment Genshin Impact Valhalla Breath of the wild Animal Crossing GTA 5 Red dead 2
Liste des sujets

probleme de convertion en haskell

_Picsou
_Picsou
Niveau 9
09 mai 2010 à 18:01:09

Bonjour j'étudis haskell et j'ai voulu écrire une petite fonction calculant les nombres premiers : http://pastebin.com/GdzZBGk2

Mais j'ai un probleme de convertion que je ne comprend pas?

dec.hs:10:22:
No instance for (RealFrac Integer)
arising from a use of `truncate' at dec.hs:10:22-40
Possible fix: add an instance declaration for (RealFrac Integer)
In the first argument of `toInteger', namely `(truncate (sqrt a))'
In the expression: toInteger (truncate (sqrt a))
In the definition of `max': max = toInteger (truncate (sqrt a))

dec.hs:10:33:
No instance for (Floating Integer)
arising from a use of `sqrt' at dec.hs:10:33-38
Possible fix: add an instance declaration for (Floating Integer)
In the first argument of `truncate', namely `(sqrt a)'
In the first argument of `toInteger', namely `(truncate (sqrt a))'
In the expression: toInteger (truncate (sqrt a))

_Picsou
_Picsou
Niveau 9
10 mai 2010 à 00:55:05

Le probleme était tout bête, j'avais oublié de convertir l'entrée

primes :: [Integer]
primes = 1 : 2 : 3 : 5 : 7 : 11 : 13 : 17 : 23 : 29 :
[ a | a <- [31,33..] , prime a ]

prime :: Integer -> Bool -- nombre impaires
prime a = prim a [3,5..max]
where
max = toInteger ( truncate ( sqrt ( fromIntegral a ) ) )

prim :: Integer -> [Integer] -> Bool
prim a [] = True
prim a n = if a `mod` (head n) /= 0
then True && prim a (tail n)
else False

Sous forums
  • Aide à l'achat Mac
  • Steam Deck
  • Création de sites web
  • Création de Jeux
  • Linux
  • Programmation
  • Internet
  • Macintosh
  • Hardware
La vidéo du moment