100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Problem Set 8 - UBC - CPSC 110 CA$10.06   Add to cart

Class notes

Problem Set 8 - UBC - CPSC 110

1 review
 643 views  23 purchases

Completed file for problem set 8. Remember to copy the pdf file to Dr Racket for a better view. This file should be exactly identical except that the file has answers for each problems.

Preview 2 out of 13  pages

  • December 20, 2022
  • 13
  • 2022/2023
  • Class notes
  • Gregor kiczales
  • All classes
All documents for this subject (19)

1  review

review-writer-avatar

By: pychew888 • 7 months ago

avatar-seller
tranghane
;; DO NOT PUT ANYTHING PERSONALLY IDENTIFYING BEYOND YOUR
CWL IN THIS FILE.
;; YOUR CWLs WILL BE SUFFICIENT TO IDENTIFY YOU AND, IF YOU HAVE
ONE, YOUR
;; PARTNER.
;;
(require spd/tags)

(@assignment psets/pset-08); Do not edit or remove this tag

;; If you are:
;; - A 110 or 107 student replace the first set of '???'s with your cwl.
;; For problem sets, If you have a partner, please replace the second
;; set of '???'s with their cwl. Remember this, it is what you will
;; do with these @cwl annotations for the whole course.
;; - A UBC Extended Learning student, replace the first set of ??? with
;; your email address as confirmed in the email you received from
;; extended learning. The handin password is also in that email.
;; Remember this, it is what you will do with these @cwl annotations
;; for the whole course.
;;
(@cwl ??? ???)

;; These problems will be autograded. NOTE that, for problems 1-5, all of the
;; following are required. Violating one or more will cause your solution to
;; receive 0 marks.
;;
;; - Files must not have any errors when the Check Syntax button is pressed.
;; Press Check Syntax and Run often, and correct any errors early.
;;
;; - The function definition MUST call one or more built-in abstract functions.
;;
;; - For maximum credit the function definition should use the most clear
;; and expressive combination of abstract functions. In particular, while
;; it is possible to just use foldr for these problems that is not always
;; correct. If what is happening is a filter, then it is not correct to
;; just implement filtering with foldr.
;;
;; - The function definition MUST NOT be recursive.
;;
;; - The function definition MUST NOT use any part of the recursive Natural

, ;; template or the (listof X) template.
;;
;; - it must not include (cond [(empty? ... anywhere
;; - it must not include (cond [(zero? ... anywhere
;; - it must not include (if (empty? ... anywhere
;; - it must not include (if (zero? ... anywhere
;;
;; - The result of the function must directly be the result of one of the
;; built-in abstract functions. So, for example, the following is not
;; a valid function body:
;;
;; (define (foo x)
;; (empty? (filter ...)))
;;
;; - You MUST NOT change or comment out any check-expects, but you are
free
;; to add new ones.

(@problem 1)
;;
;; Design a function called sum-squares that consumes a list of naturals,
;; and produces the sum of squaring all of the naturals in the list.
;;
;; For example: (sum-squares (list 5 2 4)) produces 45.
;;
;; Your function definition must use built-in abstract functions.
;; For full marks it must be a composition of exactly 2 built-in
;; abstract functions.
;;

(@htdf sum-squares) ; uncomment this when you start problem 1
(@signature (listof Natural) -> Natural)
;;produce sum of squaring all of naturals in given list

(check-expect (sum-squares empty) 0)

(check-expect (sum-squares (list 5 2 4)) 45)

(check-expect (sum-squares (list 1 1 1)) 3)

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller tranghane. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for CA$10.06. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

84866 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
CA$10.06  23x  sold
  • (1)
  Add to cart