CPSC 110 Study Guide - Winter 2018, Comprehensive Midterm Notes - Racket Programming Language, String Theory, Spider

711 views12 pages
CPSC 110
MIDTERM EXAM
STUDY GUIDE
Fall 2018
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 12 pages and 3 million more documents.

Already have an account? Log in
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 12 pages and 3 million more documents.

Already have an account? Log in
CPSC
Learning Syntax:
Athig that stats ith ; ill be regarded as notes that do not show up in DrRacket.
DrRacket
;; all values are expressions
;;
(+ 1 2)
# thing that follows the parenthesis has to be the name of the function
(+ (* 3 4) (+ 2 3))
Answer is 17
DrRacket
;; all values are expressions
;;
(+ (* 3 4) (+ 2 3))
(+ 12 (+ 2 3))
17
; ould podue  7s
;; evaluated to produce a result, in inside out left to right order
Example
c = sqrt ( a^2 + b^2)
(sqrt (+ (sqr 3) (sqr 4)))
Thee ae othe kids of alues: “tigs Ha doule uote folloed  hat ou at
followed by double quote)
- Strings are self-evaluating
(string-apped Ha Potte
Takes the to stig ad oateates the = HaPotte
 optios = Ha ,  Potte,  
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 12 pages and 3 million more documents.

Already have an account? Log in
IMAGES
(require 2htdp/image)
etagle  5 solid lue
Canadian Flag Example:
(require 2htdp/image)
(beside (rectangle 30 50 "solid" "red")
(rectangle 60 50 "solid" "white")
(rectangle 30 50 "solid" "red"))
How do we make equations simpler?
(require 2htdp/image) ; make sure to have this line at the top, otherwise circle is undefined
;(above (circle 40 "solid" "red")
; (circle 40 "solid" "yellow")
; (circle 40 "solid" "green"))
; think of f(x) = 2 + x
; f(3) = 2 + x
(define (bulb c)
(circle 40 "solid" c))
(above (bulb "red")
(bulb "yellow")
(bulb "green"))
Another example:
(define (bulb c)
(circle 40 "solid" c))
(bulb (string-append "r" "ed"))
(bulb "red")
(circle 40 "solid" "red")
; 3 red bulbs should appear
Another Problem:
Make this equation less redundant:
(* 3.14 (sqr 3))
(* 3.14 (sqr 6))
(* 3.14 (sqr 2.5))
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 12 pages and 3 million more documents.

Already have an account? Log in
ferrari12 and 39375 others unlocked
CPSC 110 Full Course Notes
23
CPSC 110 Full Course Notes
Verified Note
23 documents

Document Summary

A(cid:374)(cid:455)thi(cid:374)g that sta(cid:396)ts (cid:449)ith (cid:862);(cid:863) (cid:449)ill be regarded as notes that do not show up in drracket. ;; all values are expressions (+ 1 2) # thing that follows the parenthesis has to be the name of the function (+ (* 3 4) (+ 2 3)) ;; all values are expressions (+ (* 3 4) (+ 2 3)) (+ 12 (+ 2 3)) ;; evaluated to produce a result, in inside out left to right order. Example c = sqrt ( a^2 + b^2) (sqrt (+ (sqr 3) (sqr 4))) The(cid:396)e a(cid:396)e othe(cid:396) ki(cid:374)ds of (cid:448)alues: t(cid:396)i(cid:374)gs (cid:862)ha(cid:396)(cid:396)(cid:455)(cid:863) (cid:894)dou(cid:271)le (cid:395)uote follo(cid:449)ed (cid:271)(cid:455) (cid:449)hat (cid:455)ou (cid:449)a(cid:374)t followed by double quote) Takes the t(cid:449)o st(cid:396)i(cid:374)g a(cid:374)d (cid:272)o(cid:374)(cid:272)ate(cid:374)ates the(cid:373) = (cid:862)ha(cid:396)(cid:396)(cid:455)potte(cid:396)(cid:863) (cid:1007) optio(cid:374)s = (cid:862)ha(cid:396)(cid:396)(cid:455) (cid:862), (cid:862) potte(cid:396)(cid:863), (cid:862) (cid:862) f(3) = 2 + x. Images (require 2htdp/image) (cid:894)(cid:396)e(cid:272)ta(cid:374)gle (cid:1007)(cid:1004) 5(cid:1004) (cid:862)solid(cid:863) (cid:862)(cid:271)lue(cid:863)(cid:895)

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers