Name: Lab 3 Tasks (#S 1, 3-4 in Haskell, #2 in Scheme, All on Tux)

Name: Lab 3 Tasks (#S 1, 3-4 in Haskell, #2 in Scheme, All on Tux)

<p>CS 360 Lab 3</p><p>Name:</p><p>Lab 3 tasks (#s 1, 3-4 in Haskell, #2 in Scheme, all on tux) Access Lab 3 code you tested on tux in the preparation for Lab 3.</p><p>Part 1 (3 points) (i) In Haskell, load the file pyth.hs. Use the code of this file to find the first 5 Pythagorean triples.</p><p>(ii) In Haskell, load the file primes.hs. Use the code of this file to find the first 50 twin primes.</p><p>(iii) It is still an open mathematical problem whether there are infinitely many twin primes. Suppose that there are only finitely many twin primes. Suppose also that you have unlimited time and space resources available. Would it be possible to verify that the Haskell list of twin primes you constructed contains only finitely many items? Justify your answer.</p><p>Show the results to the TA: ______(initials) You may open another session on tux (keeping your current tux session active and available for reviewing) and proceed with the further work on Lab 3 if the TA is currently not available. </p><p>Part 2 (3 points) In Scheme, load ch4-mceval.scm. Execute the following code in the metacircular evaluator.</p><p>(define the-global-environment (setup-environment)) (driver-loop)</p><p>(define (append x y) (if (null? x) y (cons (car x) (append (cdr x) y))))</p><p>(append '(a b c) '(d e f)) (define (factorial n) (if (= n 1) 1 (* (factorial (- n 1)) n)))</p><p>(factorial 10)</p><p>Eva Lu Ator and Louis Reasoner are each experimenting with the metacircular evaluator. Eva types in the definition of map, and runs some test programs that use it. They work fine. Louis, in contrast, has installed the system version of map as a primitive for the metacircular evaluator. When he tries it, things go terribly wrong. Explain why Louis's map fails even though Eva's works.</p><p>Show the results to the TA: ______(initials). You may open another session on tux (keeping your current tux session active and available for reviewing) and proceed with the further work on Lab 3 if the TA is currently not available. </p><p>Part 3 (4 points) In Haskell, load the BST functions member and insert you prepared for the lab. Use function insert to construct a BST of height 2 consisting of numbers 1-7. Verify that all numbers 1-7 are in the BST using function member. How can you verify that the height of the tree you constructed is 2?</p><p>Show the results to the TA: ______(initials) You may open another session on tux (keeping your current tux session active and available for reviewing) and proceed with the further work on Lab 3 if the TA is currently not available. </p><p>Part 4 (extra credit, 4 points) Implement addition and multiplication of Church numerals in Haskell. Consult the Wikipedia website and its references for definitions and examples: http://en.wikipedia.org/wiki/Church_encoding</p><p>Show the results to the TA: ______(initials)</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us