DOC PREVIEW
TRINITY CSCI 1320 - Lecture Notes

This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Boolean Logic and Nesting Ifs9-21-2010Opening DiscussionLet's look at solutions to the interclass problem.Minute essay comments:Will there be a review before the test?Various decision questions.Flying pigs.Activities.MotivationI want to have a function that tells me if two squares intersect.The function will be given the x and y location of the center of each square as well as the length of the side of each square.It should return a Boolean telling if they intersect.Conditional LogicWe talked about comparisons of values in the last class.We can also combine Boolean expressions together using Boolean logic.There are four Boolean operators:&& for and|| for inclusive or^ for exclusive or! for notShort Circuit OperatorsThe && and || operators are short circuit operators.This means that if the value is known after evaluating the first operand, the second operand won't be evaluated.This can prevent errors.Let's look at an example of this with division by zero.Nesting ifsWhat you put in an if can be any expression or statement.As a result, you can put an if inside of another if.As we will see, Scala doesn't care what you nest inside of things. You write the logic that makes sense to you and says what you want to say.The match ExpressionThere is a second conditional expression in Scala called match.expr match {case patt ern => exprcase patt ern => expr...}There are lots of options for the pattern, but the simplest one is literal values.Ray TracingNow I want to start having us write some more significant code.I want to write some functions that deal with 3-D geometry with the eventual goal of being able to do ray tracing.What could we use to represent these in Scala?VectorsPointsSpheresPlanesMinute EssayIs there anything you would like to see us code? What problems do you want to be able to solve on a computer?Interclass problem:Write functions that do some operations to vectors that we didn't get to in class using


View Full Document

TRINITY CSCI 1320 - Lecture Notes

Documents in this Course
Functions

Functions

10 pages

Functions

Functions

10 pages

Graphics

Graphics

10 pages

Graphics

Graphics

11 pages

Loops

Loops

4 pages

Loops

Loops

3 pages

Strings

Strings

9 pages

Functions

Functions

10 pages

Loops

Loops

11 pages

Graphics

Graphics

11 pages

Graphics

Graphics

12 pages

Sorting

Sorting

11 pages

Sorting

Sorting

10 pages

Arrays

Arrays

10 pages

Loops

Loops

18 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?