Skip to Main Content
Professional F# 2.0
book

Professional F# 2.0

by Ted Neward, Aaron C. Erickson, Talbott Crowell, Richard Minerich
June 2010
Intermediate to advanced content levelIntermediate to advanced
432 pages
10h 44m
English
Wrox
Content preview from Professional F# 2.0

Chapter 13. Functions

WHAT'S IN THIS CHAPTER?

  • Reasoning about Functions

  • Understanding Type Restriction

  • Using First Class Functions

  • Partially Applying Functions

The way you think about functions is one of the things that most strongly differentiates F# from the other .NET languages. This doesn't come down to how functions are represented under the hood. Instead, it has more to do with the way functions are used conceptually.

When programming in F#'s functional style, functions are thought of as just another data type much like any object. They are frequently both passed into and returned from other functions. They also often have data stored inside of them through partial application or closures.

Although this can be done in other languages, it's not a frequently used feature and can take some getting used to. However, in time you will see that by leveraging these functional features more often, you can bring much to the table in terms of code succinctness and clarity. Indeed, much of F#'s power comes from this style of avoiding objects and focusing on functions.

TRADITIONAL FUNCTION CALLS

Traditionally, in mainstream imperative languages like C, C++, and C#, we treat functions as something completely different than the data that flows through our programs. They take a set of data, do some work on or with that data, and, most likely, change the state of our program in some way. They are like the channels through which the execution of our program flows, changing various data states along ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Book of F#

The Book of F#

Dave Fancher
Beginning F# 4.0

Beginning F# 4.0

Robert Pickering, Kit Eason

Publisher Resources

ISBN: 9780470528013Purchase book