This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
cs330_f2016:lab15 [2016/11/28 21:51] morse |
cs330_f2016:lab15 [2016/11/30 20:11] wingated [Hints:] |
||
---|---|---|---|
Line 81: | Line 81: | ||
* Consider using infinite lists (e.g., [2..]), higher-order functions, and list comprehension. | * Consider using infinite lists (e.g., [2..]), higher-order functions, and list comprehension. | ||
* You may find the takeWhile function to be useful. | * You may find the takeWhile function to be useful. | ||
+ | * To help you debug isPrimesFast, consider using the primes list (not the primesFast list). | ||
* Although it is not required, the functions isPrime and isPrimeFast can each be written with a single line of code. Can you figure out how? (If not, a more brute-force recursive implementation will work as well.) | * Although it is not required, the functions isPrime and isPrimeFast can each be written with a single line of code. Can you figure out how? (If not, a more brute-force recursive implementation will work as well.) | ||
* Since isPrimeFast uses the list primesFast, and primesFast is generated using isPrimeFast, you have to seed it by explicitly including that 2 is a prime number. This can be done as a special case of isPrimeFast or by starting the primesFast list as 2:<the rest of your code to generate it>. | * Since isPrimeFast uses the list primesFast, and primesFast is generated using isPrimeFast, you have to seed it by explicitly including that 2 is a prime number. This can be done as a special case of isPrimeFast or by starting the primesFast list as 2:<the rest of your code to generate it>. |