A practical example – a book publishing system
Let’s examine an example that demonstrates functional programming concepts using a book publishing system scenario:
public record Book(string Title, string Author, int Year, string Content);
// Pure function to validate a book
private static bool IsValid(Book book) =>
     !string.IsNullOrEmpty(book.Title) &&
     !string.IsNullOrEmpty(book.Author) &&
     book.Year > 1900 &&
     !string.IsNullOrEmpty(book.Content);
// Pure function to format a book
private static string FormatBook(Book book) =>
     $"{book.Title} by {book.Author} ({book.Year})";
// Higher-order function for processing books
private static IEnumerable<T> ProcessBooks<R>(
     IEnumerable<Book> books,
     Func<Book... 
                                             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
     
         
                 
                 
                 
                 
                 
                 
                 
                 
                