Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 哈斯克尔\p->;不用多久_Haskell - Fatal编程技术网

Haskell 哈斯克尔\p->;不用多久

Haskell 哈斯克尔\p->;不用多久,haskell,Haskell,在Haskell中输入以下代码: isPrime n | n <= 1 = False | n == 2 = True | n == 3 = True | even n = False | otherwise = all (\p -> not $ divideBy p n) testingSlice where testingNumbers = iterate (+ 2) 3 testingSlice = takeWhile (\p -> square p &l

在Haskell中输入以下代码:

isPrime n

| n <= 1 = False
| n == 2 = True
| n == 3 = True
| even n = False
| otherwise = all (\p -> not $ divideBy p n) testingSlice

where

  testingNumbers = iterate (+ 2) 3

  testingSlice = takeWhile (\p -> square p <= n) testingNumbers
isPrime n
|n不是$divideBy p n)测试切片
哪里
testingNumbers=迭代(+2)3
testingSlice=takeWhile(\p->square p)
检查匿名函数是否为testingSlice中的每个元素返回true


阅读。

听起来很像家庭作业,也许可以添加几行关于您到目前为止所做的事情的内容,以了解该片段中发生了什么。问题是:通过列出前六个素数:2、3、5、7、11和13,我们可以看到第六个素数是13。10 0011个素数是什么?
\p -> square p <= n
all (\p -> not $ divideBy p n) testingSlice