DOC PREVIEW
TRINITY CSCI 1320 - Recursion and Repetition

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 9Recursion and Repetition2-9-2011Opening DiscussionMinute essay comments:Copy and paste commands in vi.Let's look at solutions to the interclass problem.Finishing the intersecting squares.The match ExpressionThere is a second conditional expression in Scala called match.expr match {case pattern => exprcase pattern => expr...}There are lots of options for the pattern, but the simplest one is literal values.Lowercase names will be bound as val declarations.MotivationWe have the ability to do things once and to control whether or not certain things happen that once.Computers are really great for doing things multiple times.Reading a whole file or doing something until the user tells us to stop.Mathematical RecursionThe idea of recursion comes from mathematics.A function is recursive if it is defined in terms of itself.All recursive functions will have at least two cases.One where the function refers to itself.A base case where it doesn't refer to itself.Let's look at some examples of this.Programmatic RecursionNow I want us to write some Scala functions that are recursive.They will look much like the math functions.We have to provide a return type.One argument changes to tell us when to stop.Scripts and RedirectionOne way to process data from a file is to write a script and use redirection.scala script.scala < input.txtThis way you don't have to enter the input over and over. Also handy if the input is really large.We'll learn other ways to deal with files later.Minute EssayMake sure you are reading.What questions do you have about this topic?Minute EssayMake sure you are reading.What questions do you have about this


View Full Document

TRINITY CSCI 1320 - Recursion and Repetition

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 Recursion and Repetition
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 Recursion and Repetition 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 Recursion and Repetition 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?