Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Functional Programming with C#

You're reading from   Functional Programming with C# Unlock coding brilliance with the power of functional magic

Arrow left icon
Product type Paperback
Published in Jul 2024
Publisher Packt
ISBN-13 9781805122685
Length 258 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Alex Yagur Alex Yagur
Author Profile Icon Alex Yagur
Alex Yagur
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Part 1:Foundations of Functional Programming in C# FREE CHAPTER
2. Chapter 1: Getting Started with Functional Programming 3. Chapter 2: Expressions and Statements 4. Chapter 3: Pure Functions and Side Effects 5. Chapter 4: Honest Functions, Null, and Option 6. Part 2:Advanced Functional Techniques
7. Chapter 5: Error Handling 8. Chapter 6: Higher-Order Functions and Delegates 9. Chapter 7: Functors and Monads 10. Part 3:Practical Functional Programming
11. Chapter 8: Recursion and Tail Calls 12. Chapter 9: Currying and Partial Application 13. Chapter 10: Pipelines and Composition 14. Part 4:Conclusion and Future Directions
15. Chapter 11: Reflecting and Looking Ahead 16. Index 17. Other Books You May Enjoy

Understanding higher-order functions

In functional programming, a higher-order function is simply a function that does at least one of the following:

  • Takes one or more functions as parameters
  • Returns a function as a result

Yes, you heard it right! Higher-order functions treat functions as data, to be passed around like any other value. This leads to an unprecedented level of abstraction and code reuse.

Consider a video management system in a YouTube-like platform, where efficiently handling a large collection of videos is crucial. Instead of writing separate functions for each type of video filtering, we can utilize higher-order functions for a more elegant and reusable solution. A higher-order function can abstract the filtering logic, making the code more modular and maintainable. Here’s a simplified example:

public Func<Func<Video, bool>, IEnumerable<Video>> FilterVideos(IEnumerable<Video> videos)
{
    ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime