cs116 tutorial 1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
CS116 Tutorial 1 PowerPoint Presentation
Download Presentation
CS116 Tutorial 1

Loading in 2 Seconds...

play fullscreen
1 / 9

CS116 Tutorial 1 - PowerPoint PPT Presentation


  • 130 Views
  • Uploaded on

CS116 Tutorial 1. Review of CS115. Reminders. All assignment submissions will be ignored until Assignment 0 has been completed. Assignment 1 is due Tuesday, Jan 21 st at 11:00 am. Review of CS115 . Abstract List Functions map f ilter foldr Local Structures F oodcan.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'CS116 Tutorial 1' - beulah


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
cs116 tutorial 1

CS116 Tutorial 1

Review of CS115

reminders
Reminders
  • All assignment submissions will be ignored until Assignment 0 has been completed.
  • Assignment 1 is due Tuesday, Jan21st at 11:00 am
review of cs115
Review of CS115
  • Abstract List Functions
    • map
    • filter
    • foldr
  • Local
  • Structures
    • Foodcan
slide4

(define-structfoodcan (height radius weight label))

;; a foodcan is a structure (make-food-can h r w l)

;; where, h, r, and w are positive numbers (the

;; height in cm, radius in cm, and weight in grams,

;; respectively) and l is a symbol (the label which

;; goes on the can).

(define tomatocan (make-foodcan 10 4 400 ‘tomatoes))

(define beancan (make-foodcan 9 3 200 ‘beans))

question 1
Question 1
  • Using abstract list functions, write a Scheme function supersize-it that consumes a list of foodcansand produces a new list from it. The height and weight of each new can is twice that of the corresponding consumed foodcan, and the radius and label are unchanged.
question 2
Question 2
  • Using abstract list functions, write a functionlarge-cans that consumes a list of foodcan structures and a non-negative number, and produces a list of the labels on all the cans with weight at least as much as the consumed value.
question 3
Question 3
  • Using abstract list functions, write a function total-volume to compute the total volume of the cans in a list of foodcans.
question 4
Question 4
  • Write a functionpowers-of-two that consumes a nonnegative integer n and produces a list of integers that are the powers of 2 from 2^n down to 2^0 = 1.
  • For example, 
    • (powers-of-two 2) => (list 4 2 1)
question 5
Question 5
  • Write a functionfactors that consumes an integer n (at least 1) and returns the increasing list of all positive factors of n.
  • For example,
    • (factors 4) => (list 1 2 4)