Haskell prime test

后端 未结 5 590
醉梦人生
醉梦人生 2021-01-02 12:52

I\'m new to Haskell, and I\'m trying a bit:

isPrime :: Integer->Bool
isPrime x = ([] == [y | y<-[2..floor (sqrt x)], mod x y == 0])

I

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-02 13:32

    Regarding the second point, it stops, for example:

    [] == [x | x <- [1..]]
    

    Returns False

提交回复
热议问题