2.9 Laziness and Infinite Data
Complete this assignment with Team One.
You must submit this in an archive named "lazy.zip".
You must submit this in a file named "lazy.ss".
Develop the following functions and data structures in the Lazy Scheme language.
2.9.1 A note on testing
(printf "~S should be ~S~n" |
(take-while odd? (list 1 3 4)) |
(list 1 3)) |
2.9.2 Utility Functions
For example, (take-while (lambda (n) (< n 5)) (list 1 2 3 4 5 1 2)) returns (list 1 2 3 4).
(build-infinite-list f) → (listof any/c) |
f : (exact-nonnegative-integer? . -> . any/c) |
2.9.3 Primes
(prime? n) → boolean? |
n : exact-positive-integer? |
You may find filter, prime?, and build-infinite-list useful.
(prime?/fast n) → boolean |
n : exact-positive-integer? |
2.9.4 Longest Common Subsequence
(build-table rows cols f) → (vectorof (vectorof any/c)) |
rows : exact-positive-integer? |
cols : exact-positive-integer? |
f : (exact-nonnegative-integer? exact-nonnegative-integer? . -> . any/c) |
You will find the following function helpful:
(define (build-vector num f) |
(apply vector (build-list num f))) |
(lcs-length s1 s2) → exact-nonnegative-integer? |
s1 : string? |
s2 : string? |
You must use build-table to construct a table of the longest common subsequence of prefixes of s1 and s2 are synthesize the result from these intermediate points. You will not get credit if you do a computation twice.
You may find string-ref, char=?, apply, and max useful.
Warning: Many people errorneously implement the longest common substring. The longest common substring of Artist and Artsy is Art. The longest common subsequence of Artist and Artsy is Arts. You are implementing longest common subsequence.