DOC PREVIEW
TRINITY CSCI 1320 - Boolean Expressions

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

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

Unformatted text preview:

Boolean Expressions and if 2 2 2011 Opening Discussion Do you have any questions about the quiz Minute essay comments Solution to quadratic function Start with the math Will we learn if then Higher Order Functions This is the reason function literals exist These are functions that take other functions as arguments or return other functions The compose method is higher order We could write our own compose function that is a higher order function We will see a lot more higher order functions in chapter 7 Motivating Conditional Execution For my roller skating class I have a component of the grade based on an endurance test where you have to skate for 12 minutes This component is worth 20 points The grade you get is 0 for 20 or fewer laps and 20 for 40 or more laps Between those extremes you get one point for every lap over 20 Calculating this value requires that we do different things in different situations This is called conditional execution if The most basic form of conditional execution is the if The syntax is as follows if condition expr else expr When Scala gets to an if it evaluates the condition The condition is an expression of type Boolean If the condition is true it evaluates the first expression otherwise it evaluates the second expression Expression or Statement In Scala you can use if as an expression so it returns a value or just as a statement where you ignore the value When used as a statement the else is optional Code Blocks In Scala you can make complex statements or expressions by putting multiple statements inside of curly braces If it is used as an expression the value of the expression will be the value of the last expression in it Comparisons The condition needs to be a Boolean expression The most common basic forms of these are comparisons Use and for equality and non equality The ordering comparison operators are and Coding the Example Let s write the code for the skating problem example Guarding division is another example What are some other simple examples of places where conditional execution would be helpful Minute Essay When might you want to use conditional execution Hint any time you would use if in a sentence probably works


View Full Document

TRINITY CSCI 1320 - Boolean Expressions

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 Boolean Expressions
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 Boolean Expressions 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 Boolean Expressions 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?