anchor.diff:  
       printfn "The expression 'not boolean1 && (boolean2 || false)' is %A" boolean3
   
  -
  -
  -// ---------------------------------------------------------------
  -//         Strings
  -// ---------------------------------------------------------------
  -
  -module StringManipulation = 
  -
  +    /// Strings use double quotes.
       let string1 = "Hello"
       let string2  = "world"
   
  -    /// Use @ to create a verbatim string literal
  +    /// Strings can also use @ to create a verbatim string literal
       let string3 = @"c:\Program Files\"
   
  -    /// Using a triple-quote string literal
  +    /// String literals can also use triple-quotes
       let string4 = """He said "hello world" after you did"""
   
  -    let helloWorld = string1 + " " + string2 // concatenate the two strings with a space in between
  +    /// String concatenation is '+'. Also see String.concat, System.String.Join and others.
  +    let helloWorld = string1 + " " + string2 
       printfn "%s" helloWorld
   
  -    /// A string formed by taking the first 7 characters of one of the result strings
  +    /// Substrings use the indexer notation, for example the first 7 characters.
       let substring = helloWorld.[0..6]
       printfn "%s" substring
   
   
   
  -// ---------------------------------------------------------------
  -//         Tuples (ordered sets of values)
  -// ---------------------------------------------------------------
  -
  +/// Tuples are simple combinations of data values into a combined value.
   module Tuples = 
   
  -    /// A simple tuple of integers
  +    /// First define a simple tuple of integers.
       let tuple1 = (1, 2, 3)
   
  -    /// A function that swaps the order of two values in a tuple. 
  -    /// QuickInfo shows that the function is inferred to have a generic type.
  +    /// Next you define a function that swaps the order of two values in a tuple. 
  +    /// The function is inferred to have a generic type.
       let swapElems (a, b) = (b, a)
   
       printfn "The result of swapping (1, 2) is %A" (swapElems (1,2))
  
positive.code: 
      printfn "tuple1: %A    tuple2: %A" tuple1 tuple2
  
  
  
  // ---------------------------------------------------------------
  //         Tuples (ordered sets of values)
  // ---------------------------------------------------------------
  
  module StructTuples = 
  
      /// A simple tuple of integers
      let tuple1 = struct (1, 2, 3)
  
      /// A function that swaps the order of two values in a tuple. 
      /// QuickInfo shows that the function is inferred to have a generic type.
      let swapElems struct (a, b) = struct (b, a)
  
      printfn "The result of swapping struct (1, 2) is %A" (swapElems struct (1,2))
  
      /// A tuple consisting of an integer, a string, and a double-precision floating point number
      let tuple2 = struct (1, "fred", 3.1415)
  
      printfn "tuple1: %A    tuple2: %A" tuple1 tuple2
  
  
  
  // ---------------------------------------------------------------
  //         Lists and list processing
  // ---------------------------------------------------------------
  
  module Lists = 
  
      let list1 = [ ]            /// an empty list
  
      let list2 = [ 1; 2; 3 ]    /// list of 3 elements
  
      let list3 = 42 :: list2    /// a new list with '42' added to the beginning
  
      let numberList = [ 1 .. 1000 ]  /// list of integers from 1 to 1000
  
      /// 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) ]
  
      /// 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) ]
  
      /// Square the numbers in numberList, using the pipeline operator to pass an argument to List.map
      let squares = 
          numberList 
          |> List.map (fun x -> x*x) 
  
      /// 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)
  
  
  
  // ---------------------------------------------------------------
  //         Classes
  // ---------------------------------------------------------------
  
  module DefiningClasses = 
  
      /// The class's constructor takes two arguments: dx and dy, both of type 'float'. 
      type Vector2D(dx : float, dy : float) = 
          /// The length of the vector, computed when the object is constructed
          let length = sqrt (dx*dx + dy*dy)
  
          // 'this' specifies a name for the object's self identifier.
          // In instance methods, it must appear before the member name.
          member this.DX = dx
  
          member this.DY = dy
  
          member this.Length = length
  
          member this.Scale(k) = Vector2D(k * this.DX, k * this.DY)
      
      /// An instance of the Vector2D class
      let vector1 = Vector2D(3.0, 4.0)
  
      /// Get a new scaled vector object, without modifying the original object 
      let vector2 = vector1.Scale(10.0)
  
      printfn "Length of vector1: %f      Length of vector2: %f" vector1.Length vector2.Length
  
  
  
  // ---------------------------------------------------------------
  //         Generic classes
  // ---------------------------------------------------------------
  
  module DefiningGenericClasses = 
  
      type StateTracker<'T>(initialElement: 'T) = // 'T is the type parameter for the class
  
          /// Store the states in a list
          let mutable states = [ initialElement ]
  
          /// Add a new element to the list of states
          member this.UpdateState newState = 
              states <- newState :: states  // use the '<-' operator to mutate the value
  
          /// Get the entire list of historical states
          member this.History = states
  
          /// Get the latest state
          member this.Current = states.Head
  
      /// An 'int' instance of the state tracker class. Note that the type parameter is inferred.
      let tracker = StateTracker 10
  
      // Add a state
      tracker.UpdateState 17
  
  
  
  // ---------------------------------------------------------------
  //         Implementing interfaces
  // ---------------------------------------------------------------
  
  /// Type that implements IDisposable
  type ReadFile() =
  
      let file = new System.IO.StreamReader("readme.txt")
  
      member this.ReadLine() = file.ReadLine()
  
      // this class's implementation of IDisposable members
      interface System.IDisposable with
          member this.Dispose() = file.Close()
  
  
  
  // ---------------------------------------------------------------
  //         Arrays
  // ---------------------------------------------------------------
  
  module Arrays = 
  
      /// The empty array
      let array1 = [| |]
  
      let array2 = [| "hello"; "world"; "and"; "hello"; "world"; "again" |]
  
      let array3 = [| 1 .. 1000 |]
  
      /// An array containing only the words "hello" and "world"
      let array4 = [| for word in array2 do
                          if word.Contains("l") then 
                              yield word |]
  
      /// An array initialized by index and containing the even numbers from 0 to 2000
      let evenNumbers = Array.init 1001 (fun n -> n * 2) 
  
      /// sub-array extracted using slicing notation
      let evenNumbersSlice = evenNumbers.[0..500]
  
      for word in array4 do 
          printfn "word: %s" word
  
      // modify an array element using the left arrow assignment operator
      array2.[1] <- "WORLD!"
  
      /// 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
  // ---------------------------------------------------------------
  
  module Sequences = 
      // Sequences are evaluated on-demand and are re-evaluated each time they are iterated. 
      // An F# sequence is an instance of a System.Collections.Generic.IEnumerable<'T>,
      // so Seq functions can be applied to Lists and Arrays as well.
  
      /// The empty sequence
      let seq1 = Seq.empty
  
      let seq2 = seq { yield "hello"; yield "world"; yield "and"; yield "hello"; yield "world"; yield "again" }
  
      let numbersSeq = seq { 1 .. 1000 }
  
      /// another array containing only the words "hello" and "world"
      let seq3 = 
          seq { for word in seq2 do
                    if word.Contains("l") then 
                        yield word }
  
      let evenNumbers = Seq.init 1001 (fun n -> n * 2) 
  
      let rnd = System.Random()
  
      /// An infinite sequence which is a random walk
      //  Use yield! to return each element of a subsequence, similar to IEnumerable.SelectMany.
      let rec randomWalk x =
          seq { yield x
                yield! randomWalk (x + rnd.NextDouble() - 0.5) }
  
      let first100ValuesOfRandomWalk = 
          randomWalk 5.0 
          |> Seq.truncate 100
  
negative.code:             | Hearts -> "hearts"
          rankString  + " of " + suitString
  
      /// This example prints all the cards in a playing deck.
      let printAllCards() = 
          for card in fullDeck do 
              printfn "%s" (showCard card)
  
  
  
  /// Classes are one way of defining new object types in F#. The following example shows
  /// how a simple vector class is defined.
  module DefiningClasses = 
  
      /// The class's constructor takes two arguments: dx and dy, both of type 'double'. 
      type Vector2D(dx : double, dy : double) = 
  
          /// This internal field stores the length of the vector, computed when the 
          /// object is constructed
          let length = sqrt (dx*dx + dy*dy)
  
          // 'this' specifies a name for the object's self identifier.
          // In instance methods, it must appear before the member name.
          member this.DX = dx
  
          member this.DY = dy
  
          member this.Length = length
  
          member this.Scale(k) = Vector2D(k * this.DX, k * this.DY)
      
      /// This example defines an instance of the Vector2D class
      let vector1 = Vector2D(3.0, 4.0)
  
      /// Get a new scaled vector object, without modifying the original object 
      let vector2 = vector1.Scale(10.0)
  
      printfn "Length of vector1: %f      Length of vector2: %f" vector1.Length vector2.Length
  
  
  /// Generic classes allow types to be defined with respect to a set of type parameters.
  /// In the followiung, 'T is the type parameter for the class.
  module DefiningGenericClasses = 
  
      type StateTracker<'T>(initialElement: 'T) = 
  
          /// This internal field store the states in a list
          let mutable states = [ initialElement ]
  
          /// Add a new element to the list of states
          member this.UpdateState newState = 
              states <- newState :: states  // use the '<-' operator to mutate the value
  
          /// Get the entire list of historical states
          member this.History = states
  
          /// Get the latest state
          member this.Current = states.Head
  
      /// An 'int' instance of the state tracker class. Note that the type parameter is inferred.
      let tracker = StateTracker 10
  
      // Add a state
      tracker.UpdateState 17
  
  
  
  /// Interfaces are object types with only 'abstract' members.
  /// Object types and object expressions can implement interfaces. 
  module ImplementingInterfaces = 
  
      /// This is a type that implements IDisposable
      type ReadFile() =
  
          let file = new System.IO.StreamReader("readme.txt")
  
          member this.ReadLine() = file.ReadLine()
  
          // This is the implementation of IDisposable members
          interface System.IDisposable with
              member this.Dispose() = file.Close()
  
  
      /// This is an object that implements IDisposable.  Unlike
      /// C#, a new type definition is not needed to implement an interface
      /// you can just use an object expression instead.
      let interfaceImplementation =
          { new System.IDisposable with
              member this.Dispose() = printfn "disposed" }
  
  
  
  
  /// Option values are any kind of value tagged with either 'Some' or 'None'.
  /// They are used extensively in F# code to represent the cases where many other
  /// languages would use null references.
  module OptionValues = 
  
      /// First, define a type of ZipCodes.
      type ZipCode = ZipCode of string
  
      /// Next, define a type where the ZipCode is optionsl.
      type Customer = { ZipCode : ZipCode option }
  
      /// Next, define an interface type the represents an object to compute the shipping zone for the customer's zip code, 
      /// given implementations for the 'getState' and 'getShippingZone' abstract methods.
      type ShippingCalculator =
          abstract GetState : ZipCode -> string option
          abstract GetShippingZone : string -> int
  
      /// Next calculate a shipping zone for a customer using a calculator instance.
      let CustomerShippingZone (calculator: ShippingCalculator, customer: Customer) =
          customer.ZipCode |> Option.bind calculator.GetState |> Option.map calculator.GetShippingZone
  
  
  
  /// Numeric types can be annotated with units.  F# arithmetic correctly computes the adjusted
  /// numeric types.
  module UnitsOfMeasure = 
  
      /// First open a collection of common unit names
      open Microsoft.FSharp.Data.UnitSystems.SI.UnitNames
  
      /// Define a unitized constant
      let sampelValue1  = 1600.0<meter>          
  
      /// Next, define a new unit type
      [<Measure>]
      type mile =
          /// Conversion factor mile to meter.
          static member asMeter = 1609.34<meter/mile>
  
      /// Define a unitized constant
      let sampleValue2  = 500.0<mile>          
  
      /// Compute  metric-system constant
      let sampleValue3 = sampleValue2 * mile.asMeter   
  
      printfn "After a %A race I would walk %A miles which would be %A meters" sampelValue1 sampleValue2 sampleValue3
  
  
  
  /// The FSharp.Core library defines a range of parallel processing functions.  Here
  /// you use some functions for parallel processing over arrays.
  module ParallelArrayProgramming = 
                
      ///
      /// First, an array of inputs.
      let oneBigArray = [| 0 .. 100000 |]
      
      // Next, define a functions that does some CPU intensive computation.
      let rec computeSomeFunction x = 
          if x <= 2 then 1 
          else computeSomeFunction (x - 1) + computeSomeFunction (x - 2)
         
      // Next, do a parallel map over a large input array
      let computeResults() = oneBigArray |> Array.Parallel.map (fun x -> computeSomeFunction (x % 20))
  
      // Next, print the results.
      printfn "Parallel computation results: %A" (computeResults())
  
  
  
  /// Events are a common idiom for .NET programming.
  module Events = 
  
      /// First, create instance of Event object that consists of subscription point (event.Publish) and event trigger (event.Trigger)
      let simpleEvent = new Event<int>() 
  
      // Next, add handler to the event
      simpleEvent.Publish.Add(
          fun x -> printfn "this is handler was added with Publish.Add: %d" x)
  
      // Next, trigger the event
      simpleEvent.Trigger(5)
  
      // Next, create an instance of Event that follows standard .NET convention: (sender, EventArgs)
      let eventForDelegateType = new Event<EventHandler, EventArgs>()
  
      // Next, add a handler for this new event
      eventForDelegateType.Publish.AddHandler(
          EventHandler(fun _ _ -> printfn "this is handler was added with Publish.AddHandler"))
  
      // Next, trigger this event (note that sender argument should be set)
      eventForDelegateType.Trigger(null, EventArgs.Empty)
  
  
  