User Tools

Site Tools


cs330_f2016:lab15

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
cs330_f2016:lab15 [2016/11/30 20:11]
wingated [Hints:]
cs330_f2016:lab15 [2018/03/30 03:51]
morse
Line 84: Line 84:
   * 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>.
-  * For the lcsLength function, you will need to use an array rather than lists so that you can have random access into the table.  ​See the Haskell ​documentation ​for how to do this.+  * For the lcsLength function, you will need to use an array rather than lists so that you can have random access into the table.  ​Here is a tutorial on Haskell ​arrays ​for how to do this:​https://​www.haskell.org/​tutorial/​arrays.html. ​ In particular, pay attention to the "​wavefront"​ example.
   * To access an element of a string, use the "​!!"​ operator. ​ For example, s1!!j returns the jth element of the string s1 (using zero-based indexing).   * To access an element of a string, use the "​!!"​ operator. ​ For example, s1!!j returns the jth element of the string s1 (using zero-based indexing).
   * Here's some code for a simple function that returns the largest Int value smaller than the square root of another Int.  It's pretty straightforward,​ but it does involve some type conversions that we want to spare you from having to figure out.   * Here's some code for a simple function that returns the largest Int value smaller than the square root of another Int.  It's pretty straightforward,​ but it does involve some type conversions that we want to spare you from having to figure out.
cs330_f2016/lab15.txt ยท Last modified: 2021/06/30 23:42 (external edit)