; stuff - anything from a semicolon to the ; end of a line is a Racket COMMENT, and will ; be ignored! ;===== ; expression: a "chunk" that has meaning in ; a programming language ;===== ; simple expression: the simplest form of ; expression ; what you can DO with an expression ; is based on its DATA TYPE ; the syntax of a simple expression ; determines its data type ;===== ; for data type number, I must follow ; Racket's syntax rules for its ; number type -- 1 or more digits, ; possibly started with a -, ; possibly containing ONE decimal point: 4 10000 42 42.20 000003 .00003 -34 -3.4 ; data type string: anything in double-quotes ; is considered a simple expression of ; type string "moo" "duck" "Zeke" "-34" ;===== ; Boolean type: #true #false #true #false ;===== ; and image is supported as a simple ; expression type in Racket ; if you copy an image DrRacket, it is considered ; a simple expression of type image;===== ; compound expressions! ; in Beginning Student Language (BSL) ; Racket, a compound expression has ; THIS syntax: ; (operation argument-expression1 ; argument-expression2 ; ... ; ) ; ; * the argument expressions following ; the operation are separated by blanks ; or newlines (not commas!) ; ; * the data type of a compound expression ; is the data type of the value its operation ; computes, of the value its operation ; RETURNS ; ; * how many argument expressions you can have ; depends on the operation -- each operation ; expects a particular number and type ; of argument expressions ;===== ; SO -- what kind of operations are available in Racket? ; ; * has some built-in operators ; * has some built-in functions ; * has some available modules, collections or ; libraries of additional operators and functions ; * AND... you can write your OWN operations, your own ; functions! <-- starting next week! ; ; here are a FEW of the built-in operations... ;===== ; arithmetic operators! ; * such as: + - * / ; ; * these expect two or more argument expressions, ; each of type number, ; and return a number that is the result of ; performing that arithmetic operator on ; those argument expressions (+ 4 3 7 42 20 17 10000 500 1 19) (- 4 3) (* 4 3) (/ 4 3) ;===== ; some operations return types other than number, ; and some operations have names -- these are FUNCTIONS! ;===== ; string-append expects two or more argument ; expressions of type string, and returns ; a single string expression consisting ; of the values of its arguments appended ; (smushed) together (string-append "me" "ow") ;===== ; operator = expects two or more arguments of type ; number, and returns whether all of ; its arguments have the same value (= (- 4 3) 1) ;===== ; the require funcction is special -- ; it expects the name of a Racket module, ; a collection of Racket definitions, ; and it returns NOTHING (!!), ; BUT has the SIDE-EFFECT of making ; those definitions available for use in ; the rest of this Definitions ; window/in expressions in the rest of ; this .rkt file! ; 2htdp/image is the image library provided ; by the "How to Design Programs", 2nd edition ; text! (require 2htdp/image) ;===== ; one operation 2htdp/image provides is a ; star function -- ; it expects the desired distance between ; a 5-pointed star's points in pixels, ; a style string "solid" or "outline", ; and a color, and it returns an image ; of a star of that size, style, and color! (star 30 "solid" "purple")