; Sharon Tuttle and Sharon Tuttle ; (put your names in a comment) ; week 1 lab ; 2016-08-26 ; simple expression of type number 1 ; simple expression of type string "howdy" ; simple expression of type boolean #true ; simple expression of type image; recall the syntax for BSL Racket ; compound expressions: ; ; (operation expression ... ) ; NOTE that the operation is often a ; function name... ; NOTE that the expressions after the ; operation can be simple or compound ; NEW THING: we often call the expressions ; after the operation in a compound ; expression that compound expression's ; ARGUMENTS ; NOTE that a particular operation/function ; expects argument expressions of ; particular types! ; it is a syntax error if you give an ; operation an argument of an incorrect ; type ; uncomment to see the error ;(+ #true 56) ; there are built in arithmetic operators ; + - * / ; there are many built in functions ; sqrt ceiling floor and more ; NOTICE -- I need to tell you HOW MANY ; and WHAT TYPE arguments an operation ; or function expects!!! ; + - * / expect at least two arguments ; of type number ; sqrt and ceiling and floor expect ; exactly one argument of type number ; there are functions for strings ; (and functions that result in strings ; NOTE!!! ; the type of a compound expression ; is the type of its resulting/returned ; value!! ; string-append - expects zero or more string expressions, ; and returns a new string that is the ; arguments squished together (string-append "dog" "boy") (string-append "al" "ph" "a") ; string? expects anything and returns a boolean, ; giving whether or not that expression is a ; string ; (yes, image? and number? and boolean? all ; also exist...) ; you can see if two string expressions have the ; the same value with ; string=? (string=? "moo" (string-append "m" "oo")) ; there also exist number=? and boolean=? and image=? ; and, sometimes you can convert an expression ; of one type into an expression of another ; string->number expects one string argument ; and returns a numeric version if it can ; and #false otherwise (string->number "13") (string->number "moo") ; number->string expects one number argument ; a returns a string version of it (number->string 13) (number->string (/ 3 4)) ; oh yes -- number simple expressions can include ; a / (a rational number) ; this is a simple expression of type number (number? 3/4) ; BSL Racket has several built-in collections ; of goodies called teachpacks ; and if you include them with a require expression, ; you can use them ; 2htdp/image has many image functions used in the ; course text; ; 2htdp/universe has functions for animations (require 2htdp/image) (circle 30 "solid" "blue") (rectangle 10 60 "outline" "red") (overlay (circle 30 "solid" "yellow") )