Solutions
I hope you did all the exercises and just want to check out my solutions. If not, don’t worry, everything comes with experience. Now, let’s look at the solutions.
Exercise 1
Use the Map
method to apply a function to each tower in the list that appends “(Upgraded)” to its name:
public Result<List<Tower>, string> UpgradeTowers(Result<List<Tower>, string> towersResult) { return towersResult.Map(towers => towers.Select(tower => { tower.Name += " (Upgraded)"; return tower; }).ToList());}
This solution demonstrates how functors can encapsulate data and behavior, allowing for operations on contained...