Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
F# for C# Developers
A Note Regarding Supplemental Files
Foreword
Introduction
Who Should Read This Book
Who Should Not Read This Book
Organization of This Book
Finding Your Best Starting Point in This Book
Conventions and Features in This Book
System Requirements
Code Samples
Installing the Code Samples
Using the Code Samples
Acknowledgments
Errata & book support
We want to hear from you
Stay in touch
I. C# and F#
1. C# and F# Data Structures
Basic Data Types
Triple-Quoted Strings
Variable Names
Flow Control
for Loop
while Loops
if Expressions
Match
Console Output
Run Your Program
Creating a Console Application
Using F# Interactive
FSIAnyCPU
FSI Directives
Compiler Directives
Some Useful Add-ins
List, Sequence, and Array Data Structures
Lists
Sequences
Arrays
Pipe-Forward Operator
The Sequence, List, and Array Module Functions
length
exists and exists2
forall and forall2
find
map
filter
fold
collect
append
Math Operations
zip and zip3
rev
sort
Convert to Seq/List/Array
Convert from Seq/List/Array
What Changed
Other F# Types
Defining Constants by Using Attributes
Enumerations
Tuples
Functions
Recursive Functions
Pipe/Composite Operators
Unit Types
Type Aliases
Type Inferences
Interop and Function Parameters
Module, Namespace, and Program Entry Points
2. Using F# for Object-Oriented Programming
Using Classes
Adding Fields
Defining a Property
Defining a Method
Defining a Static Method
Using Constructors
Creating an Indexer
Using a Self-Identifier
Using a Special/Reserved Member Name
Using Inheritance
Using Abstract and Sealed Classes
Creating an Instance
Using Type Casting
Converting Numbers and Using enum
Upcasting and Downcasting
Boxing and Unboxing
Defining an Interface
Using the IDisposable Interface
Using F# Generic Types and Constraints
Defining Structure
Using Extension Methods
Using Operator Overloading
Using Delegates and Events
Interoperating with a C# Project
Adding a Reference
Using AssemblyInfo
Real-World Samples
Using the WPF Converter
Using ObservableCollection with List Features
3. F# and Design Patterns
Using Object-Oriented Programming and Design Patterns
Working with F# and Design Patterns
Working with the Chain of Responsibility Pattern
Working with the Adapter Pattern
Working with the Command Pattern
Working with the Observer Pattern
Working with the Decorator Pattern
Working with the Proxy Pattern
Working with the Strategy Pattern
Working with the State Pattern
Working with the Factory Pattern
Working with the Singleton Pattern
Working with the Composite Pattern
Working with the Template Pattern
Working with the Private Data Class Pattern
Working with the Builder Pattern
Working with the Façade Pattern
Working with the Memento Pattern
Writing Design Patterns: Additional Notes
II. F#’s Unique Features
4. Type Providers
Using the LINQ-to-SQL Type Provider
SQL Type Provider Parameters
SQL Entity Type Provider
SQL Entity Type Provider Parameters
WSDL Type Provider
WSDL Type Provider Parameters
OData Type Provider
OData Type Provider Parameters
Other Type Providers
Query
Using the select Operator
Using the where Operator
Using the join Operator
Using the sortBy Operator
Using the group Operator
Using the take and skip Operators
Using the min/max, average, and sum Operators
Using the head, last, and nth Operators
Using the count and distinct Operators
Using the contains, exists, and find Operators
Using the exactlyOne and all Operators
SQL Query and F# Query
Other F# Operators
Using a Type Provider to Connect to the Windows Azure Marketplace
Setting Up the Azure Account
Connecting To and Consuming Data
Performing Translations with Microsoft Translator
Storing Data Locally
Performing Serialization
Exporting to Microsoft Excel
Generating a Word Document
5. Write Your Own Type Provider
What Is a Type Provider?
Setting Up the Development Environment
Exploring the HelloWorld Type Provider
Using the Regular-Expression Type Provider
Using the CSV Type Provider
Using the Excel-File Type Provider
Using the Type-Provider Base Class
Sharing Information Among Members
Using a Wrapper Type Provider
Using the Multi-Inheritance Type Provider
Using the XML Type Provider
Using the DGML-File Type Provider
Separating Run Time and Design Time
Generated Type Provider
Using Type-Provider Snippets
Type-Provider Limitations
6. Other Unique Features
Working with Reference Cells
Working with Object Expressions
Working with Options
Working with Units of Measure
Working with Records
Using the CLIMutable Attribute
Comparing a Record with Other Data Structures
Working with Discriminated Unions
Working with Comparison Operations for a Record, Tuple, and DU
Using Pattern Matching
Using the Tuple Pattern
Using the List and Array Patterns
Using the NULL Pattern
Using the Record and Identifier Patterns
Working with the And/Or Pattern and Pattern Grouping
Using Variable Patterns and the when Guard
Using the Type Pattern and as pattern
Using the Choice Helper Type
Working with Active Patterns
Using Single-Case Active Patterns
Using Partial-Case Active Patterns
Using Multicase Active Patterns
Using Parameterized Active Patterns
Working with Exceptions
Catching Exceptions
Throwing Exceptions
Defining Exceptions
Working with a Generic Invoke Function
Using the inline function
Working with Asynchronous and Parallel Workflows
Using Threads
Using Asynchronous Workflows
Working with the Asynchronous Programming Model
Handling Exceptions
Using Cancellation
Building Your Own Asynchronous Primitives
Debugging Multithreaded Applications
Using Agents
Working with Computation Expressions
Using Computation Expression Attributes
Using Computation Expression Sample
Using Reflection
Defining Attributes
Working with Type and Member Info
Using Reflection on F# Types
Using Tuples
Using Functions Related to Discriminated Unions
Using Functions Related to Records
Using Exceptions with F#
Function
Checking F# Types
Working with Code Quotation
Working with the Observable Module
Using Lazy Evaluation, Partial Functions, and Memoization
Summary
III. Real-World Applications
7. Portable Library and HTML/JavaScript
Developing Windows Store Applications with F#
Creating an F# Portable Library
Using the CompiledName Attribute
Exploring the Portable Library Samples
Developing the WinRT Application
Using an Array, List, and Seq
Sorting data types
Using a quick-sort algorithm
Performing a merge sort
Finding a sum from an array
Merging two sorted arrays
Finding the maximum sum of an array
Finding the median of two sorted arrays
Dealing with the Dutch national flag problem
Finding the longest increasing sequence
Creating a Tree Structure
F# tree representation and traversal
F# binary tree and in-order traversal
Binary search tree
Delete a tree
Build a tree from pre-order and in-order sequences
Build a BST from a pre-order iteration list
Check that a BST has only one child
Find the common elements from two BSTs
Find the tree diameter
Find the lowest common ancestor
Validate the sum of all child nodes
Calculate the tree boundary
Using String Operations
Substring
Palindrome in a string
Permutations of a string
String interleaving
KMP string search algorithm
Using the Graph Library
Depth-first search
Breadth-first search
Find all paths in a graph
A* algorithm
Dijkstra algorithm
Examining Other Samples
Combination
Phone keyboard
Shuffle algorithm
Reservoir sampling
Check intersecting line segments
Find triangles
Neural network
Using the Continuation Passing Style
Working with HTML5 and WebSharper
Creating an ASP.NET Website with WebSharper
Using a Formlet Type to Get Input and Generate Output
Using a Formlet Type as a Wizard
Creating an HTML5 Page
8. Cloud and Service Programming with F#
Introducing Windows Azure
Setting Up Your Environment
Developing a Windows Azure Application
Azure Cloud Queue
Azure WCF Service
Azure Blob Storage
Azure SQL Database
Code Snippet for Azure Development
MapReduce
MapReduce Design Patterns
Genetic Algorithms on Cloud
Understanding Genetic Algorithms
Selection
Crossover and Mutation
Elitism
Azure Communication
Setting Up the Service from Azure Management Portal
Service-Side Code
Client-Side Code
Genetic Algorithms in the Cloud
9. GPGPU with F#
Introducing GPU and GPGPU
CUDA
CUDA Toolkit
cuRAND Library
cuBLAS Library
F# Quotation and Transform
F# Quotation on GPGPU
Pascal Triangle
Using Binomial Trees and the BOPM
Maximum Values in Subarrays
Using the Monte Carlo Simulation to Compute the π Value on a GPU
Useful Resources
In Closing
A. About the Author
Index
About the Author
Copyright
← Prev
Back
Next →
← Prev
Back
Next →