CPSC 110 Lecture Notes - Operand

23
CPSC 110 Full Course Notes
Verified Note
23 documents
Document Summary
Use all caps for constants, use for separating words, To evaluate numbers: ( primitive operator operand use this to evaluate operand until it"s a value) (/ 9 3) (+ 1 2) = 1+2 (/2 1) = 2/1 etc. *use step (top right corner) to see step by step stuff. Exercise: evaluate (* (+ 4 (-7 3) 1) 2) To make shape: (rectangle width height mode color ) Mode=solid, outline i. e. (require 2htdp/image) (rectangle 50 70 solid blue ) You can define a picture as a constant e. g. (define blue-square ((copy pic)) ) To put images beside each other (beside blue-square tiger) (beside name1 name2) Making sentences: adding phrases/strings together: use string-append, i. e. (string-append blu likes red ) => blu likes red ( is for space) Write expression for total cost of buying 2 adult tickets & 3 kid tickets for. . 75/adult and . 75/kid. (define adult-fare 2. 75) (define kid-fare 1. 75) (+ (* adult-fare 2) (* kid-fare 1. 75))