From the course: Advanced C#: Functional Programming Patterns

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Pipelining with extension methods

Pipelining with extension methods - C# Tutorial

From the course: Advanced C#: Functional Programming Patterns

Pipelining with extension methods

- [Narrator] There's another functional composition pattern called pipelining. It's more popular than the previous example I showed you, and it's what's used in places in DyNet, like link. In fact, I predict if you were to talk to a C# developer or some .NET developers and talk about functional composition, they would think we're talking about pipelining, not the other example. The way we're going to implement this is using extension methods. I have them in this extensions class, and here's the key for making this an extension method. And the first parameter in this case is an int. To make pipelining work, the return type from this method also has to be an int. And you'll see that that's the case in all of my pipeline methods. Now the code itself is exactly the same code that we saw on the previous video. I have one called to fourth power, which is taking the number and multiplying by itself four times, I have a make…

Contents