Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个表达式,例如:
[2] ++ sieve [3,5..] where sieve (p:xs) = p : sieve [i | i <- xs, i `mod` p /= 0]
我将如何(在函数中)获取该列表的前n 个元素?我知道该take功能,但我不知道如何在这种情况下使用它。
take
我知道这个表达式创建了一个无限的素数列表。我试图找出提取前n 个素数。