anchor.diff:          elif a < b then greatestCommonFactor a (b - a)
           else greatestCommonFactor (a - b) b
   
  -    /// Computes the sum of a list of integers using recursion.
  +    /// Thsi example shows a recursive function that computes the sum of a list of integers.
       let rec sumList xs =
           match xs with
           | []    -> 0
           | y::ys -> y + sumList ys
   
  -    /// Make the function tail recursive, using a helper function with a result accumulator
  -    let rec private sumListTailRecHelper accumulator xs =
  -        match xs with
  -        | []    -> accumulator
  -        | y::ys -> sumListTailRecHelper (accumulator+y) ys
  -
  -    let sumListTailRecursive xs = sumListTailRecHelper 0 xs
  -
  -
  -
  -// ---------------------------------------------------------------
  -//         Record types
  -// ---------------------------------------------------------------
  -
  +
  +/// A record is a collection of data items brought together into one object.
   module RecordTypes = 
   
  -    // define a record type
  +    /// This example shows how to define a new record type.  
       type ContactCard = 
  -        { Name     : string;
  -          Phone    : string;
  +        { Name     : string
  +          Phone    : string
             Verified : bool }
                 
  -    let contact1 = { Name = "Alf" ; Phone = "(206) 555-0157" ; Verified = false }
  -
  -    // create a new record that is a copy of contact1, 
  -    // but has different values for the 'Phone' and 'Verified' fields
  -    let contact2 = { contact1 with Phone = "(206) 555-0112"; Verified = true }
  -
  -    /// Converts a 'ContactCard' object to a string
  -    let showCard c = 
  +    /// This example shows how to define an instance of a record type.
  +    let contact1 = 
  +        { Name = "Alf" 
  +          Phone = "(206) 555-0157" 
  +          Verified = false }
  +
  +    /// This example shows how to use "copy-and-update" on record values. It creates 
  +    /// a new record value that is a copy of contact1, but has different values for 
  +    /// the 'Phone' and 'Verified' fields
  +    let contact2 = 
  +        { contact1 with 
  +            Phone = "(206) 555-0112"
  +            Verified = true }
  +
  +    /// This example shows how to write a function that processes a record value.
  +    /// It converts a 'ContactCard' object to a string.
  +    let showCard (c: ContactCard) = 
           c.Name + " Phone: " + c.Phone + (if not c.Verified then " (unverified)" else "")
           
   
   
  -// ---------------------------------------------------------------
  -//         Union types
  -// ---------------------------------------------------------------
  -
  +/// Union types represent different possibilites for kinds of data.
   module UnionTypes = 
   
  -    /// Represents the suit of a playing card
  +    /// For example, the following represents the suit of a playing card.
       type Suit = 
           | Hearts 
           | Clubs 
           | Diamonds 
           | Spades
   
  -    /// Represents the rank of a playing card
  +    /// A union type can also be used to represent the rank of a playing card.
       type Rank = 
           /// Represents the rank of cards 2 .. 10
           | Value of int
  
positive.code: 
  
  
  // ---------------------------------------------------------------
  //         Recursive functions
  // ---------------------------------------------------------------
  
  module RecursiveFunctions  = 
                
      /// Compute the factorial of an integer. Use 'let rec' to define a recursive function
      let rec factorial n = 
          if n = 0 then 1 else n * factorial (n-1)
  
      /// Computes the greatest common factor of two integers. 
      //  Since all of the recursive calls are tail calls, the compiler will turn the function into a loop,
      //  which improves performance and reduces memory consumption.
      let rec greatestCommonFactor a b =
  
negative.code: 
      printfn "tuple1: %A    tuple2: %A" tuple1 tuple2
  
      /// A simple tuple of integers, represented as a flat inline struct (a value-type)
      let sampleStructTuple = struct (1, 2, 3)
  
  
  // ---------------------------------------------------------------
  //         Lists, Arrays and data processing
  // ---------------------------------------------------------------
  
  /// Lists, arrays and sequences are basic collection types in F# programming.
  /// Many other collection types are available in System.Collections.Generic,
  /// System.Collections.Immutable and other libraries.
  module ListsAndArrays = 
  
      /// Lists are defined using [ ... ].  This is an empty list.
      let list1 = [ ]  
  
      /// This is a list with 3 elements.
      let list2 = [ 1; 2; 3 ]
  
      /// This is a list of integers from 1 to 1000
      let numberList = [ 1 .. 1000 ]  
  
      /// Lists can also be generated by computations. This is a list containing 
      /// all the days of the year.
      let daysList = 
          [ for month in 1 .. 12 do
                for day in 1 .. System.DateTime.DaysInMonth(2012, month) do 
                    yield System.DateTime(2012, month, day) ]
  
      /// Computations can include conditionals.  This is a list containing the tuples
      /// which are the coordinates of the black squares on a chess board.
      let blackSquares = 
          [ for i in 0 .. 7 do
                for j in 0 .. 7 do 
                    if (i+j) % 2 = 1 then 
                        yield (i, j) ]
  
      /// Lists can be transformed using 'List.map' and other functional programming combinators.
      /// This definition produces a new list by squaring the numbers in numberList, using the pipeline 
      /// operator to pass an argument to List.map.
      let squares = 
          numberList 
          |> List.map (fun x -> x*x) 
  
      /// There are many other list combinations. The following computes the sum of the squares of the 
      /// numbers divisible by 3.
      let sumOfSquares = 
          numberList
          |> List.filter (fun x -> x % 3 = 0)
          |> List.sumBy (fun x -> x * x)
  
      /// Arrays are like lists, but are stored 'flat' (rather than as immutable linked lists), and
      /// are mutable (their contents can be changed). This is The empty array.
      let array1 = [| |]
  
      /// Arrays are specified using the same range of constructs as lists.
      let array2 = [| "hello"; "world"; "and"; "hello"; "world"; "again" |]
  
      /// This is an array of numbers from 1 to 1000.
      let array3 = [| 1 .. 1000 |]
  
      /// This is an array containing only the words "hello" and "world"
      let array4 = 
          [| for word in array2 do
                 if word.Contains("l") then 
                     yield word |]
  
      /// This is an array initialized by index and containing the even numbers from 0 to 2000
      let evenNumbers = Array.init 1001 (fun n -> n * 2) 
  
      /// Sub-arrays are extracted using slicing notation.
      let evenNumbersSlice = evenNumbers.[0..500]
  
      /// You can loop over lists and arrays using 'for' loops.
      for word in array4 do 
          printfn "word: %s" word
  
      // You can modify the contents of an an array element by using the left arrow assignment operator.
      array2.[1] <- "WORLD!"
  
      /// You can transform arrays using 'Array'map' and other functional programming operations.
      /// The following calculates the sum of the lengths of the words that start with 'h'
      let sumOfLengthsOfWords = 
          array2
          |> Array.filter (fun x -> x.StartsWith "h")
          |> Array.sumBy (fun x -> x.Length)
  
  
  /// Sequences are evaluated on-demand and are re-evaluated each time they are iterated. 
  /// An F# sequence is just a System.Collections.Generic.IEnumerable<'T>.
  /// Sequence processing functions can be applied to Lists and Arrays as well.
  module Sequences = 
  
      /// This is the empty sequence.
      let seq1 = Seq.empty
  
      /// This a sequence of values.
      let seq2 = seq { yield "hello"; yield "world"; yield "and"; yield "hello"; yield "world"; yield "again" }
  
      /// This is an on-demand sequence from 1 to 100.
      let numbersSeq = seq { 1 .. 1000 }
  
      /// This is a sequence producing the words "hello" and "world"
      let seq3 = 
          seq { for word in seq2 do
                    if word.Contains("l") then 
                        yield word }
  
      /// This sequence producing the even numbers up to 2000.
      let evenNumbers = Seq.init 1001 (fun n -> n * 2) 
  
      let rnd = System.Random()
  
      /// This is an infinite sequence which is a random walk.
      /// This example uses yield! to return each element of a subsequence.
      let rec randomWalk x =
          seq { yield x
                yield! randomWalk (x + rnd.NextDouble() - 0.5) }
  
      /// This example shows the first 100 elements of the random walk.
      let first100ValuesOfRandomWalk = 
          randomWalk 5.0 
          |> Seq.truncate 100
  