anchor.diff:      [1,2] = toList(append([1], [2])),
       ok.
   
  +length_test() ->
  +    3 = length([1,2,3]),
  +    0 = length(seq([])),
  +    ok.
  +
   collect_test() ->
       [1, -1, 2, -2, 3, -3] = toList(collect(fun (X) -> [X, -X] end, [1,2,3])),
       ok.
   
  +compareWith_test() ->
  +    Comparer = fun (X, X) -> 0;
  +                   (_, _) -> 99
  +               end,
  +    0 = compareWith(Comparer, [1,2,3], [1,2,3]),
  +    99 = compareWith(Comparer, [1,2,3], [1,3,2]),
  +    -1 = compareWith(Comparer, [1,2], [1,2,3]),
  +    1 = compareWith(Comparer, [1,2,3], [1,2]),
  +    ok.
  +
  +
   take_test() ->
       [1,2] = toList(take(2, [1,2,3])),
  -    ok.
  -
  +    [1,2] = toList(truncate(2, [1,2,3])),
  +    ?assertException(throw, {'System.InvalidOperationException', _}, toList(take(2, []))),
  +    [1,2,3] = toList(truncate(5, [1,2,3])),
  +    [1,2] = toList(takeWhile(fun(I) -> I < 3 end, [1,2,3])),
  +    ok.
  +
  +nth_test() ->
  +    1 = nth(0, [1,2,3]),
  +    3 = nth(2, [1,2,3]),
  +    1 = item(0, [1,2,3]),
  +    3 = item(2, [1,2,3]),
  +    ?assertException(throw, {'System.ArgumentException', _}, nth(5, [])),
  +    ?assertException(throw, {'System.ArgumentException', _}, item(5, [])),
  +    ok.
  +
  +min_max_test() ->
  +    1 = min([1,2,3]),
  +    3 = max([1,2,3]),
  +    ?assertException(throw, {'System.ArgumentException', _}, min([])),
  +    ?assertException(throw, {'System.ArgumentException', _}, max([])),
  +    ok.
  +
  +pairwise_test() ->
  +    [] = toList(pairwise([])),
  +    [] = toList(pairwise([1])),
  +    [{1,2}] = toList(pairwise([1,2])),
  +    [{1,2},{2,3}] = toList(pairwise([1,2,3])),
  +    [{1,2},{2,3},{3,4}] = toList(pairwise([1,2,3,4])),
  +    ok.
  +
  +skip_test() ->
  +    [3] = toList(skip(2, [1,2,3])),
  +    [3] = toList(skipWhile(fun(I) -> I < 3 end, [1,2,3])),
  +    ok.
   -endif.
  
positive.code: head(Seq) ->
      case next(seq(Seq)) of
          finished ->
              throw(argument_exception);
          {Item, _Seq} ->
              Item
      end.
  
negative.code: collect(F, Sources) ->
      {seq, {collect, F, seq(Sources)}}.
  
  % Returns the first non-zero result from the comparison function.
  % If the end of a sequence is reached it returns a -1 if the first sequence
  % is shorter and a 1 if the second sequence is shorter.
  compareWith(Comparer, Seq1, Seq2) ->
      Compare = fun Compare(S1, S2) ->
                      case {next(S1), next(S2)} of
                          {finished, finished} -> 0;
                          {finished, _} -> -1;
                          {_, finished} -> 1;
                          {{I1, S1_2}, {I2, S2_2}} ->
                              case Comparer(I1, I2) of
                                  0 ->
                                      % they are the same - continue
                                      Compare(S1_2, S2_2);
                                  Res ->
                                      Res
                              end
                      end
              end,
      Compare(seq(Seq1), seq(Seq2)).
  
  concat(Sources) ->
      {seq, {concat, undefined, seq(Sources)}}.
  
  contains(Item, Seq) ->
      find_internal(seq(Seq), fun (I) -> I =:= Item end) =/= undefined.
  
  tail(Seq) ->
      skip(1, Seq).
  
  take(Num, Seq) ->
      {seq, {take, Num, seq(Seq)}}.
  
  takeWhile(Pred, Seq) ->
      {seq, {take_while, Pred, seq(Seq)}}.
  
  toList(Seq) ->
      enumerate(seq(Seq), []).
  
  truncate(Num, Seq) ->
      {seq, {truncate, Num, seq(Seq)}}.
  
  tryFind(Pred, Seq) ->
      case find_internal(seq(Seq), Pred) of
          undefined ->
              undefined;
          {_Index, Item} ->
              Item
      end.
  
  tryFindIndex(Pred, Seq) ->
      case find_internal(seq(Seq), Pred) of
          undefined ->
              undefined;
          {Index, _Item} ->
              Index
      end.
  
  ofList(List) when is_list(List) ->
      seq(List).
  
  pairwise(Seq) ->
      {seq, {pairwise, undefined, [], seq(Seq)}}.
  
  pick(Picker, Seq) ->
      case pick_internal(seq(Seq), Picker) of
          undefined ->
              throw_key_not_found_exn();
          Item ->
              Item
      end.
  
  tryPick(Picker, Seq) ->
      pick_internal(seq(Seq), Picker).
  
  % casts lists (and others) to seq
  seq(L) when is_list(L) ->
  