140 likes | 238 Views
GBK Programming 1. Jordan Johnson Introducing DrRacket. Today’s plan. Greetings GBK Today Class Web site DrRacket and programming Assignments Clean-up. DrRacket : Anatomy. Evaluate the definitions. Definitions. Interactions. Important Terms. Definitions area:
E N D
GBK Programming 1 Jordan Johnson Introducing DrRacket
Today’s plan Greetings GBK Today Class Web site DrRacketand programming Assignments Clean-up
DrRacket: Anatomy Evaluate the definitions Definitions Interactions
Important Terms • Definitions area: • area for writing programs • “Save” saves its contents • “Run” computes the results of its contents • Interactions area: • area for testing & experimentation • DrRacket prompts you for a program… • …and then returns your program’s result. • Programs consist of expressions
Simple programs in BSL • (BSL = “Beginning Student Language”) • Expressions are one of the following: • something simple (a number), or • ( …more than one thing… ) • Compound expressions always start & end with parens.
Simple programs (refined) • Expressionsare one of the following: • something simple (a number), or • (AN-OPERATION AN-EXPRESSION …) • AN-OPERATION stands for the name of some operation like +, *, sin, and so on… • When you see a “(“, the thing afterwards is always* an operation.
“Something simple”:more than numbers • Other types of data: • strings: • “howdy there” • “55” • booleans: • true • false • images:
Operations • On numbers: • +, -, *, /, expt, sin, … • <, >, <=, >=, = • On strings: • string-length • string-append • substring • On booleans: • and • Or
Practice • Use the Interactions window to try some operations: • Multiply three or four numbers • Take the square root of a number • Add two numbers and convert the result to a string • Append several strings together • Compute the length of a string
Expressions inside expressions • As the definition of expressions suggests, we can nest them: • (number->string (string-length “potato”)) “6” • (sqrt (+ (* 5 5) (* 12 12))) 13
Definitions • The top half of the window is the Definitions area. • Executed when you click “Run”. • Contents remain saved. • Can contain expressions and definitions. • Example definitions: • (define x 8) • (define y 36)
To Learn More The Help Desk lets you search for particular functions. If your cursor is on a function name, pressing F1 looks up the function’s help info.
Due Date Reminders • By tomorrow: • Sign & return syllabus • Email me your HW #1 • All instructions are on the class website.
Clean-up • Before you leave, please . . . • Log out. • Push in your chair. • Make sure you’ve got everything. • Make sure all trash ends up in the trash can.