anchor.diff:  
   == What Option changes to our example
   
  -Using `Option` to represent optional data instead of a list brings some benefits in the sense that a program is often easier to read if we can easily distinguish between true lists (which can containing any number of elements) and singleton lists representing optional data (which can only contain zero or one element). By the way, the difference is not always visible since type may sometimes be inferred, such as when chaining methods. Here is our `pack` method using `Option` instead of `List` for optional data:
  +Using `Option` to represent optional data instead of a list brings some benefits in the sense that a program is often easier to read if we can easily distinguish between true lists (which can contain any number of elements) and singleton lists representing optional data (which can only contain zero or one element). By the way, the difference is not always visible since type may sometimes be inferred, such as when chaining methods. Here is our `pack` method using `Option` instead of `List` for optional data:
   
   [source,java]
   ----
  
positive.code: }
  ----
  
  <1> The flatMap method can't be used, since it produces a `List` Here, we produce an `Option`, but this would not be visible if we had kept the name `flatMap` for the method. We will of course have to define the `Option.sequence` method.
  
  <2> The `map` method is called on an `Option`, but it is difficult to see by looking at the code!
  
  <3> Getting the value (if present) or a default value (if not) is done through the `getOrElse` method. We changed the name to follow current usage although is is implemented through a fold!
  
  <4> We can simplify getting the value or default value from the resulting `Option`.
  
  The `map` and `getOrElse` method can be seen in the previous listing of the `Option` class. You can see that `Option` is really a `List`. The problem happen when a list is mapped with a function returning an `Option`. When we were using a list for optional data, the function was returning a `List`, so we ended with a `List<List<A>>`. Getting a `List<A>` instead was just a matter of using `flatMap` instead of `Map`. With `Option`, we end with a List<Option<A>. So we have to create a method for this. We will put it in the `List` class. By convention, this method is called `sequence`. In order to better mimic the `List.flatMap` method, we will also add a convenience `sequence` method taking a function returning an `Option` as its argument:
  
  [source,java]
  ----
  
negative.code: 
  (2) A list of integers is build by first creating a list of integers from the given capacity to 1. The `range` method must be added to the `List` class.
  
  (3) This list of integers is mapped to a list of knapsacks. While constructing this list (named `acc`, for "accumulator", by convention), the previously created knapsacks are available.
  
  (4) We filter the items so that we won't try to insert items with a weight higher than what the knapsack may contain.
  
  (5) We look for a previously created knapsack of index `item.weight - 1`. The `List.at(n)` method has to be created and it will return optional data, which mean a list of zero (not found) or one (found) knapsack. If this knapsack is found, the item is added to it, which is done by mapping the function `k -> k.add(item)` to the singleton knapsack list.
  
  (6) From the resulting list, we select the knapsack with the maximum value.
  
  (7) The resulting value is added to the (head of) accumulator. This concludes the function used for folding the list of integers, in (3).
  
  (8) Once the list of integers is folded to a list of knapsacks, we just have to select the maximum value, which is automatically the head of the list. As the head method returns a singleton list, we use a "getOrElse" technique to select either the value if it is present, or a default value if not.
  
  The technique used here is very well none in functional programming and is called memoization. It consists in keeping access to the previous results instead of recomputing them at each step. This technique is also used in imperative programming. The particularity of the functional programming version is the way the previous results are transported in the fold (in the `acc` parameter).
  
  == Implementing the missing methods
  
  In this example, we have used two new methods that are missing in the `List` class. The `range` method is a convenience method allowing creating a list of integers from `start` (included) to `end` (excluded) if `start` is lower than `end`. Otherwise, the list is constructed in reverse order. The fact that `start` is included and `end` is excluded is purely conventional. Here is the corresponding implementation in the `List` class:
  
  [source,java]
  ----
  