Join Todd McLeod for an in-depth discussion in this video Understanding recursion, part of Code Clinic: Go.
- View Offline
- Exercise Files
- Let's take a look at how recursion works,…and then, after we've done that, we will take a look…at how recursion is being used to walk…through all of this directory.…We'll see how "filepath-walk" is implemented…in the standard library…and we'll see recursion at use there.…To understand recursion, I think "factorial" is…the best example to begin with.…Here's the basic idea of recursion.…We have "func main" and, in here,…we're calling function, "factorial,"…and factorial's going to return an "int"…and we're passing into at "4" as an argument.…
Factorial has a parameter of wanting an int,…and we are passing in 4 as an argument.…Just making a distinction there…between parameter and argument.…What this does is, if x equals "zero,"…then we're going to return "one."…Otherwise, we're going to return "x"…multiplied by "factorial (x-1)."…We're calling factorial again, and we're passing…in a new number, and then that's…going to return a number.…There's functions nested within functions…nested within functions.…When you first come across this,…
Todd introduces challenges and then provides overviews of his solutions in Go. Challenges include topics such as statistical analysis, searching directories for images, and accessing peripheral devices.
Skill Level Beginner
Google App Engine Essential Trainingwith Joseph Lowery3h 26m Intermediate
1. Problem 1—Exploring Lake Pend Oreille
2. Problem 2—Image Analysis
3. Problem 3—Eight Queens
4. Problem 4—Accessing Peripherals
5. Problem 5—Recursion and Directories
6. Problem 6—Building the Web
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.