With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

Book Description

LINQ draws on principles of functional programming and represents a paradigm shift for developers used to an imperative/object oriented programming style. Thinking in LINQ explains the benefits of functional programming built into LINQ, allowing developers to use these techniques write more efficient and concise data-intensive applications.

While other books on the subject merely scratch the surface in terms of problem solving using LINQ, Thinking in LINQ shows readers how use functional programming techniques to solve common every-day problems as well as more complex problems using LINQ’s features.

LINQ lets you write code that resembles natural language and is easier to debug compared to traditional loops and branching statements. The purpose of a well written LINQ Query will be immediately evident unlike the looping construct so commonly used in traditional programming. LINQ operators can be used in unison to orchestrate a solution for complex real world problems.

1. Cover
2. Title
4. Dedication
5. Contents at a Glance
6. Contents
9. Acknowledgments
10. Introduction
11. Chapter 1: Thinking Functionally
1. 1-1. Understanding Functional Programming
2. 1-2. Using Func<> in C# to Represent Functions
3. 1-3. Using Various Types of Functions
4. 1-4. Understanding the Benefits of Functional Programming
12. Chapter 2: Series Generation
1. 2-1. Math and Statistics: Finding the Dot Product of Two Vectors
2. 2-2. Math and Statistics: Generating Pythagorean Triples
3. 2-3. Math and Statistics: Finding a Weighted Sum
4. 2-4. Math and Statistics: Finding the Percentile for Each Element in an Array of Numbers
5. 2-5. Math and Statistics: Finding the Dominator in an Array
6. 2-6. Math and Statistics: Finding the Minimum Number of Currency Bills Required for a Given Amount
7. 2-7. Math and Statistics: Finding Moving Averages
8. 2-8. Math and Statistics: Finding a Cumulative Sum
9. 2-9. Recursive Series and Patterns: Generating Recursive Structures by Using L-System Grammar
10. 2-10. Recursive Series and Patterns Step-by-Step Growth of Algae
11. 2-11. Recursive Series and Patterns: Generating Logo Commands to Draw a Koch Curve
12. 2-12. Recursive Series and Patterns: Generating Logo Commands to Draw a Sierpinski Triangle
13. 2-13. Recursive Series and Patterns: Generating Fibonacci Numbers Nonrecursively (Much Faster)
14. 2-14. Recursive Series and Patterns: Generating Permutations
15. 2-15. Recursive Series and Patterns: Generating a Power Set of a Given Set
16. 2-16. Collections: Picking Every n th Element
17. 2-17. Collections: Finding the Larger or Smaller of Several Sequences at Each Index
18. 2-18. Number Theory: Generating Armstrong Numbers and Similar Number Sequences
19. 2-19. Number Theory: Generating Pascal’s Triangle Nonrecursively
20. 2-20. Game Design: Finding All Winning Paths in an Arbitrary Tic-Tac-Toe Board
21. 2-21. Series in Game Design: Solving Go Figure
22. 2-22. Miscellaneous Series: Finding Matching Pairs from Two Unsorted Collections
23. 2-23. Miscellaneous Series: Using a Lookup-Based Approach
24. 2-24. Miscellaneous Series: Solving the FizzBuzz Challenge in a LINQ One-Liner
25. 2-25. Miscellaneous Series: Solving the FizzBuzz Challenge by Using Set Theory
26. Summary
13. Chapter 3: Text Processing
1. 3-1. Simulating a T9 Word Suggestion
2. 3-2. Simulating a Gesture Keyboard
3. 3-3. Cloning Peter Norvig’s Spelling-Correction Algorithm
4. 3-4. Reversing a Sentence Word by Word
5. 3-5. Creating a Word Triangle
6. 3-6. Finding Anagrams
7. 3-7. Checking for Anagrams Without Sorting Characters
8. 3-8. Creating a Rudimentary Programming Language Identifier and Automatic Syntax Highlighter
9. 3-9. Creating a Word-Ladder Solver
10. 3-10. Formatting on the Fly
11. 3-11. Solving Eric Lippert’s Comma-Quibbling Problem
12. 3-12. Generating Random Serials
13. 3-13. Generating All Substrings of a Given String
14. 3-14. Creating a Scrabble Cheater
15. 3-15. Finding All the Subsequences of a Given String
16. 3-16. Squeezing a Paragraph to Fill Tightly
17. 3-17. Printing the Lines of a Song
18. 3-18. Mining Abbreviations and Full Forms from News Articles
19. Summary
14. Chapter 4: Refactoring with LINQ
1. 4-1. Replacing Loops by Using LINQ Operators
2. 4-2. The Any Operator
3. 4-3. The All Operator
4. 4-4. The Take Operator
5. 4-5. The Skip Operator
6. 4-6. The TakeWhile Operator
7. 4-7. The SkipWhile Operator
8. 4-8. The Where Operator
9. 4-9. The Zip Operator
10. 4-10. OrderBy and OrderByDescending Operators
11. 4-11. The Distinct Operator
12. 4-12. The Union Operator
13. 4-13. The Intersect Operator
14. 4-14. The Except Operator
15. 4-15. The Concat Operator
16. 4-16. The SequenceEqual Operator
17. 4-17. The Of Type Operator
18. 4-18. The Cast Operator
19. 4-19. The Aggregate Operator
20. 4-20. Replacing Nested Loops
21. 4-21. Running Code in Parallel Using AsParallel( ) and AsOrdered( ) Operators
22. Summary
15. Chapter 5: Refactoring with MoreLINQ
1. 5-1. Getting MoreLINQ
2. 5-2. Using the Scan Operator
3. 5-3. Using the Slice Operator
4. 5-4. Using the Interleave Operator
5. 5-5. Using the Windowed Operator
6. 5-6. Using the Cartesian Operator
7. 5-7. Using the Partition Operator
8. 5-8. Using the Index Operator
9. 5-9. Using the PairWise Operator
10. 5-10. The ForEach Operator
11. 5-11. Using the MinBy/MaxBy Operator
12. Summary
16. Chapter 6: Creating Domain-Specific Languages
1. 6-1. Feel the Difference
2. 6-2. Creating a Simple DSL for Mathematicians
3. 6-3. Testing Armstrong by Using NUnit
4. 6-4. Exposing Armstrong as an External DSL
5. 6-5. Cloning Handy F# Functions by Using LINQ
6. 6-6. Lazily Generating Items from a Recurrence Relation
7. Summary
17. Chapter 7: Static Code Analysis
1. 7-1. Finding Verbose Type Names in the .NET 3.5 Framework
2. 7-2. Finding the Number of Overloads for a Method
3. 7-3. Finding the Size of a Namespace
4. 7-4. Finding the Code-to-Comment (C# Style) Ratio
5. 7-5. Finding the Size of Types
6. 7-6. Generating Documentation Automatically
7. 7-7. Finding Inheritance Relationships
8. 7-8. Locating Complex Methods
9. Summary
18. Chapter 8: Exploratory Data Analysis
1. 8-1. Analyzing the Titanic Survivors Dataset
2. 8-2. Converting SurveyMonkey Results to CSV
3. 8-3. Analyzing Trends in Baby Names
4. 8-4. Analyzing Stock Values
5. 8-5. Analyzing Git Logs
6. 8-6. Analyzing Movie Ratings
7. 8-7. Identifying Flowers by Using Machine Learning
8. Summary
19. Chapter 9: Interacting with the File System
1. 9-1. Comparing Two CSV Files
2. 9-2. Finding the Total File Size in a Directory
3. 9-3. Cloning LINUX Head and Tail Commands
4. 9-4. Locating Files with the Same Name (Possible Duplicates)
5. 9-5. Finding Exact-Duplicate Files
7. 9-7. Finding Files Modified Last Week
8. 9-8. Locating Dead Files (Files with Zero Bytes)
20. Appendix A: Lean LINQ Tips
1. Tip 1
2. Tip 2
3. Tip 3
4. Tip 4
5. Tip 5
6. Tip 6
7. Tip 7
8. Tip 8
9. Tip 9
10. Tip 10
11. Tip 11
12. Tip 12
13. Tip 13
14. Tip 14
15. Tip 15
16. Tip 16
17. Tip 17
21. Appendix B: Taming Streaming Data with Rx.NET
1. A Brief Explanation of the Interfaces
2. Getting Rx.NET