You are previewing Expert F# 3.0, Third Edition.

Expert F# 3.0, Third Edition

Cover of Expert F# 3.0, Third Edition by Don Syme... Published by Apress
  1. Titlepage
  2. Dedication
  3. Contents at a Glance
  4. Contents
  5. About the Authors
  6. About the Technical Reviewer
  7. Acknowledgments
  8. Chapter 1: Introduction
    1. The Genesis of F#
    2. About This Book
    3. Who This Book Is For
  9. Chapter 2: Your First F# Program – Getting Started With F#
    1. Creating Your First F# Program
    2. Using Object-Oriented Libraries from F#
    3. Summary
  10. Chapter 3: Introducing Functional Programming
    1. Starting with Numbers and Strings
    2. Working with Conditionals: && and ||
    3. Defining Recursive Functions
    4. Lists
    5. Options
    6. Getting Started with Pattern Matching
    7. Introducing Function Values
    8. Summary
  11. Chapter 4: Introducing Imperative Programming
    1. About Functional and Imperative Programming
    2. Imperative Looping and Iterating
    3. Using Mutable Records
    4. Using Mutable Locals
    5. Working with Arrays
    6. Introducing the Imperative .NET Collections
    7. Exceptions and Controlling Them
    8. Having an Effect: Basic I/O
    9. Combining Functional and Imperative: Efficient Precomputation and Caching
    10. Combining Functional and Imperative: Functional Programming with Side Effects
    11. Summary
  12. Chapter 5: Understanding Types in Functional Programming
    1. Exploring Some Simple Type Definitions
    2. Understanding Generics
    3. Making Things Generic
    4. More on Different Kinds of Types
    5. Understanding Subtyping
    6. Troubleshooting Type-Inference Problems
    7. Summary
  13. Chapter 6: Programming with Objects
    1. Getting Started with Objects and Members
    2. Using Classes
    3. Adding Further Object Notation to Your Types
    4. Defining Object Types with Mutable State
    5. Getting Started with Object Interface Types
    6. More Techniques to Implement Objects
    7. Combining Functional and Objects: Cleaning Up Resources
    8. Extending Existing Types and Modules
    9. Working with F# Objects and .NET Types
    10. Summary
  14. Chapter 7: Encapsulating and Organizing Your Code
    1. Hiding Things
    2. Organizing Code with Namespaces and Modules
    3. Reusing Your Code
    4. Summary
  15. Chapter 8: Working with Textual Data
    1. Building Strings and Formatting Data
    2. Parsing Strings and Textual Data
    3. Using XML as a Concrete Language Format
    4. Some Recursive Descent Parsing
    5. Binary Parsing and Formatting
    6. Summary
  16. Chapter 9: Working with Sequences and Structured Data
    1. Getting Started with Sequences
    2. More on Working with Sequences
    3. Structure Beyond Sequences: Working with Trees
    4. Active Patterns: Views for Structured Data
    5. Equality, Hashing, and Comparison for New Structured Data Types
    6. Tail Calls and Recursive Programming
    7. Summary
  17. Chapter 10: Numeric Programming and Charting
    1. Basic Charting with FSharpChart
    2. Basic Numeric Types and Literals
    3. Sequences, Statistics and Numeric Code
    4. Statistics, Linear Algebra and Distributions with Math.NET
    5. Units of Measure
    6. Summary
  18. Chapter 11: Reactive, Asynchronous, and Parallel Programming
    1. Introducing Some Terminology
    2. Events
    3. Using and Designing Background Workers
    4. Introducing Asynchronous and Parallel Computations
    5. Agents
    6. Observables
    7. Using Shared-Memory Concurrency
    8. Summary
  19. Chapter 12: Symbolic Programming with Structured Data
    1. Verifying Circuits with Propositional Logic
    2. Symbolic Differentiation and Expression Rendering
    3. Summary
  20. Chapter 13: Integrating External Data and Services
    1. Some Basic REST Requests
    2. Getting Started with Type Providers and Queries
    3. More on Queries
    4. More on Relational Databases and ADO.NET
    5. Using WSDL Services
    6. Summary
  21. Chapter 14: Building Smart Web Applications
    1. Serving Web Content the Simple Way
    2. Building Ajax Rich Client Applications
    3. Summary
  22. Chapter 15: Building Mobile Web Applications
    1. Web-based vs. Native Mobile Applications
    2. Feature Detection and Polyfilling in WebSharper
    3. Mobile Capabilities, Touch Events, and Mobile Frameworks
    4. Serving Mobile Content
    5. Building a Mobile Web Application for iOS Devices
    6. Developing Social Networking Applications
    7. WebSharper Mobile
    8. Developing Android Applications with WebSharper
    9. Summary
  23. Chapter 16: Visualization and Graphical User Interfaces
    1. Writing “Hello, World!” in a Click
    2. Understanding the Anatomy of a Graphical Application
    3. Composing User Interfaces
    4. Drawing Applications
    5. Writing Your Own Controls
    6. Displaying Samples from Sensors
    7. Creating a Mandelbrot Viewer
    8. Windows Presentation Foundation
    9. Summary
  24. Chapter 17: Language-Oriented Programming: Advanced Techniques
    1. Computation Expressions
    2. Using F# Reflection
    3. Using F# Quotations
    4. Summary
  25. Chapter 18: Libraries and Interoperating with Other Languages
    1. Types, memory and interoperability
    2. Libraries: A High-Level Overview
    3. Using the System Types
    4. Using Further F# and .NET Data Structures
    5. Supervising and Isolating Execution
    6. Further Libraries for Reflective Techniques
    7. Some Other .NET Types You May Encounter
    8. Under the Hood: Interoperating with C# and other .NET Languages
    9. COM Interoperability
    10. Interoperating with C and C++ with PInvoke
    11. Summary
  26. Chapter 19: Packaging, Debugging and Testing F# Code
    1. Packaging Your Code
    2. Debugging Your Code
    3. Debugging and Testing with F# Interactive
    4. Testing Your Code
    5. Summary
  27. Chapter 20: Designing F# Libraries
    1. Designing Vanilla .NET Libraries
    2. Understanding Functional Design Methodology
    3. Applying the .NET Library Design Guidelines to F#
    4. Some Recommended Coding Idioms
    5. Summary
  28. Appendix: F# Brief Language Guide
    1. Comments and Attributes
    2. Basic Types and Literals
    3. Types
    4. Patterns and Matching
    5. Functions, Composition, and Pipelining
    6. Binding and Control Flow
    7. Exceptions
    8. Tuples, Arrays, Lists, and Collections
    9. Operators
    10. Type Definitions and Objects
    11. Namespaces and Modules
    12. Sequence Expressions and Workflows
    13. Queries and Quotations
  29. Index
O'Reilly logo

CHAPTER 4

images

Introducing Imperative Programming

In Chapter 3, you saw some of the constructs that make up F# functional programming. At the core of the functional-programming paradigm is “programming without side effects,” called pure functional programming. In this chapter you learn about programming with side effects, called imperative programming.

About Functional and Imperative Programming

In the functional programming paradigm, programs compute the result of a mathematical expression and don’t cause any side effects, simply returning the result of the computation. The formulas used in spreadsheets are often pure, as is the core of functional-programming ...

The best content for your career. Discover unlimited learning on demand for around $1/day.