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/28 20:19]
wingated [Resources:]
cs330_f2016:lab15 [2016/11/28 21:51]
morse
Line 43: Line 43:
 <code haskell> <code haskell>
 -- Type Signature -- Type Signature
-isPrimeFast :: Int -> bool+isPrimeFast :: Int -> Bool
 </​code>​ </​code>​
 Takes an integer n and returns true if n is prime. Takes an integer n and returns true if n is prime.
Line 85: Line 85:
   * 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. ​ See the Haskell documentation for how to do this.
   * 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.
 +<​code>​
 +iSqrt :: Int-> Int
 +iSqrt n = floor(sqrt(fromIntegral n))
 +</​code>​
  
 ---- ----
cs330_f2016/lab15.txt ยท Last modified: 2021/06/30 23:42 (external edit)