← Înapoi la Urmăritori

Cel mai recent articol

Ultima verificare

Urmăritori 0 urmăritori
Articole: 193
  1. Expressions vs. statements

    In programming language terminology, an “expression” is a combination of values and functions that are combined and interpreted by the compiler to create a new value, as opposed to a “statement” which is just a standalone unit of execution and doesn’t ret…

  2. Expressions and syntax: Introduction

    NOTE: Before reading this series, I suggest that you read the “thinking functionally” series as a prerequisite.

  3. Attaching functions to types

    Although we have focused on the pure functional style so far, sometimes it is convenient to switch to an object oriented style.

  4. Organizing functions

    Now that you know how to define functions, how can you organize them?

  5. Function signatures

    It may not be obvious, but F# actually has two syntaxes - one for normal (value) expressions, and one for type definitions.

  6. Defining functions

    We have seen how to create typical functions using the “let” syntax, below: let add x y = x + y In this section, we’ll look at some other ways of creating functions, and tips for defining functions.

  7. Function associativity and composition

    Function associativity If we have a chain of functions in a row, how are they combined?

  8. Partial application

    In the previous post on currying, we looked at breaking multiple parameter functions into smaller one parameter functions.

  9. Currying

    After that little digression on basic types, we can turn back to functions again, and in particular the puzzle we mentioned earlier: if a mathematical function can only have one parameter, then how is it possible that an F# function can have more than one?

  10. How types work with functions

    Now that we have some understanding of functions, we’ll look at how types work with functions, both as domains and ranges.

  11. Function Values and Simple Values

    Let’s look at the simple function again let add1 x = x + 1 What does the “x” mean here?

  12. Mathematical functions

    The impetus behind functional programming comes from mathematics.

  13. Thinking Functionally: Introduction

    Now that you have seen some of the power of F# in the “why use F#" series, we’re going to step back and look at the fundamentals of functional programming – what does it really mean to “program functionally”, and how this approach is different from object…

  14. Why use F#: Conclusion

    This completes the tour of F# features.

  15. Anything C# can do...

    As should be apparent, you should generally try to prefer functional-style code over object-oriented code in F#, but in some situations, you may need all the features of a fully fledged OO language – classes, inheritance, virtual methods, etc.

  16. We have already seen many examples of F#’s use with the .NET libraries, such as using System.Net.WebRequest and System.Text.RegularExpressions.

  17. Completeness

    In this final set of posts, we will look at some other aspects of F# under the theme of “completeness”.

  18. Functional Reactive Programming

    Events are everywhere.

  19. Messages and Agents

    In this post, we’ll look at the message-based (or actor-based) approach to concurrency.

  20. Asynchronous programming

    In this post we’ll have a look at a few ways to write asynchronous code in F#, and a very brief example of parallelism as well.

  21. Concurrency

    We hear a lot about concurrency nowadays, how important it is, and how it is “the next major revolution in how we write software”.

  22. In this post, we’ll see how you can design for correctness (or at least, for the requirements as you currently understand them), by which I mean that a client of a well designed model will not be able to put the system into an illegal state – a state that…

  23. You are familiar with static type checking through languages such as C# and Java.

  24. Exhaustive pattern matching

    We briefly noted earlier that when pattern matching there is a requirement to match all possible cases.

  25. Immutability

    To see why immutability is important, let’s start with a small example.

  26. Correctness

    As a programmer, you are constantly judging the code that you and others write.

  27. Active patterns

    F# has a special type of pattern matching called “active patterns” where the pattern can be parsed or detected dynamically.

  28. Partial Application

    A particularly convenient feature of F# is that complicated functions with many parameters can have some of the parameters fixed or “baked in” and yet leave other parameters open.

  29. Functions as interfaces

    An important aspect of functional programming is that, in a sense, all functions are “interfaces”, meaning that many of the roles that interfaces play in object-oriented design are implicit in the way that functions work.

  30. Out-of-the-box behavior for types

    One nice thing about F# is that most types immediately have some useful “out-of-the-box” behavior such as immutability and built-in equality, functionality that often has to be explicitly coded for in C#.

  31. Convenience

    In the next set of posts, we will explore a few more features of F# that I have grouped under the theme of “convenience”.

  32. Pattern matching for conciseness

    So far we have seen the pattern matching logic in the match..with expression, where it seems to be just a switch/case statement.

  33. Using functions as building blocks

    A well-known principle of good design is to create a set of basic operations and then combine these building blocks in various ways to build up more complex behaviors.

  34. In the very first example in this series, we saw a simple function that calculated the sum of squares, implemented in both F# and C#.

  35. Low overhead type definitions

    In C#, there is a disincentive for creating new types – the lack of type inference means you need to explicitly specify types in most places, resulting in brittleness and more visual clutter.

  36. Type inference

    As you have already seen, F# uses a technique called “type inference” to greatly reduce the number of type annotations that need to be explicitly specified in normal code.

  37. Conciseness

    After having seen some simple code, we will now move on to demonstrating the major themes (conciseness, convenience, correctness, concurrency and completeness), filtered through the concepts of types, functions and pattern matching.

  38. Four Key Concepts

    In the next few posts we’ll move on to demonstrating the themes of this series: conciseness, convenience, correctness, concurrency and completeness.

  39. In this example, we will compare the F# and C# code for downloading a web page, with a callback to process the text stream.

  40. Comparing F# with C#: Sorting

    In this next example, we will implement a quicksort-like algorithm for sorting lists and compare an F# implementation to a C# implementation.

  41. Comparing F# with C#: A simple sum

    To see what some real F# code looks like, let’s start with a simple problem: “sum the squares from 1 to N”.

  42. F# syntax in 60 seconds

    Here is a very quick overview on how to read F# code for newcomers unfamiliar with the syntax.

  43. Introduction to the 'Why use F#' series

    This series of posts will give you a guided tour through the main features of F# and then show you ways that F# can help you in your day-to-day development.