Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Functional Programming with C#
  • Table Of Contents Toc
  • Feedback & Rating feedback
Functional Programming with C#

Functional Programming with C#

By : Alex Yagur
close
close
Functional Programming with C#

Functional Programming with C#

By: Alex Yagur

Overview of this book

In an era where software complexity is increasing by the day, functional programming offers a paradigm that simplifies code maintenance and enhances reliability. Functional Programming with C# takes you on an exhaustive journey into functional programming within C#. The book familiarizes you with the core principles and benefits of functional programming, juxtaposing it with imperative and object-oriented paradigms. You’ll get to grips with the functional features of C# and learn to write expressive, modular code through expressions, pure functions, and higher-order functions. As you advance, you’ll explore advanced concepts such as error handling and asynchronous programming, which will equip you with the practical skills that you need to tackle real-world challenges. By comparing functional programming in C# with other languages and providing additional resources, this book ensures that you’re well-equipped to continue your journey toward mastery in functional programming. By the end of this book, you’ll have gained a thorough understanding of functional programming techniques, such as recursion, memoization, and composition, empowering you to write robust, maintainable code.
Table of Contents (18 chapters)
close
close
Free Chapter
1
Part 1:Foundations of Functional Programming in C#
6
Part 2:Advanced Functional Techniques
10
Part 3:Practical Functional Programming
14
Part 4:Conclusion and Future Directions

Exercises

After explaining the concepts, Julia challenged Steve to apply what he’d learned.

Julia: Now that you understand the basics, why don’t you try refactoring your game’s upgrade system using monads? It should make your code more robust and easier to reason about.

Steve: That’s a great idea! I can already see how this could simplify some of my more complex game logic.

Exercise 1

Given a Result<List<Tower>, string> type that represents a list of towers, where Tower is a class containing properties such as Id, Name, and Damage, the task is to use the functor concept to apply a function to each tower that appends “(Upgraded)” to the end of its name to indicate that the tower has been upgraded:

public class Tower
{
    public int Id { get; set; }
    public string Name { get; set; }
    public int Damage { get; set; }
}
public Result<List<Tower&gt...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY