From the course: Grasshopper and Rhino: C# Scripting

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Recursion

Recursion

From the course: Grasshopper and Rhino: C# Scripting

Start my 1-month free trial

Recursion

- [Tutor] In this lesson, we'll learn about recursive functions and how to create one. First off, what is recursion? Well, recursion is the process in which a function makes a call to itself. The function is then called a recursive function. An example is the subdivision of this rectangle. Say we wanted a recursive function to subdivide this rectangle repeatedly. We might create a method called MakeSplit, which takes a rectangle as a parameter and splits it in half, producing two equal rectangles. For this to be recursive, it then makes a call to itself within the MakeSplit function. So in this case, instead of just returning that rectangle, it might use it with another MakeSplit function, producing two more rectangles. This continues to occur recursively, executing it over and over until some condition causes it to stop or the computer crashes. So let's give that a try in Rhino. As you can see, I currently have the…

Contents