anchor.diff:  
   -export_type([seq/0]).
   
  +append(Seq1, Seq2) ->
  +    {seq, {append, first, seq(Seq1), seq(Seq2)}}.
  +
  +average(Seq) ->
  +    averageBy(fun id/1, Seq).
  +
  +averageBy(F, Seq) ->
  +    Aggr = fun ({C, Sum}, N) -> {C+1, Sum + N} end,
  +    {Num, Total} =
  +        case next(seq(Seq)) of
  +            finished ->
  +                % no items in sequence
  +                throw(argument_exception);
  +            {Item, Enum} ->
  +                aggregate(Enum, {1, F(Item)}, Aggr)
  +        end,
  +    Total / Num.
  +
   empty() ->
       {seq, {list, []}}.
   
   singleton(Item) ->
       {seq, {list, [Item]}}.
   
  -append(Seq1, Seq2) ->
  -    {seq, {append, first, seq(Seq1), seq(Seq2)}}.
  -
   map(F, Seq) ->
       {seq, {map, F, seq(Seq)}}.
   
  +exists(F, Seq) ->
  +    find_internal(seq(Seq), F) =/= undefined.
  +
   filter(Pred, Seq) ->
       {seq, {filter, Pred, seq(Seq)}}.
   
  +find(Pred, Seq) ->
  +    case find_internal(seq(Seq), Pred) of
  +        undefined ->
  +            throw(key_not_found_exception);
  +        {_Index, Item} ->
  +            Item
  +    end.
  +
  +findIndex(Pred, Seq) ->
  +    case find_internal(seq(Seq), Pred) of
  +        undefined ->
  +            throw(key_not_found_exception);
  +        {Index, _Item} ->
  +            Index
  +    end.
  +
  +fold(Folder, State, Seq) ->
  +    aggregate(seq(Seq), State, Folder).
  +
  +head(Seq) ->
  +    case next(seq(Seq)) of
  +        finished ->
  +            throw(argument_exception);
  +        {Item, _Seq} ->
  +            Item
  +    end.
  +
  +init(Num, Gen) ->
  +    {seq, {iter, 0, Num, Gen}}.
  +
  +isEmpty(Seq) ->
  +    next(seq(Seq)) =:= finished.
  +
  +iter(Action, Seq) ->
  +    ignore = aggregate(Seq, ignore, fun (S, I) ->
  +                                            Action(I),
  +                                            S
  +                                    end),
  +    unit.
  +
  +
   delay(F) ->
       {seq, {delay, F}}.
   
  +choose(Chooser, Seq) ->
  +    filter(fun(I) ->
  +                   Chooser(I) =/= undefined
  +           end, seq(Seq)).
  +
   collect(F, Sources) ->
       {seq, {collect, F, seq(Sources)}}.
  +
  +concat(Sources) ->
  +    {seq, {concat, undefined, seq(Sources)}}.
  +
  +contains(Item, Seq) ->
  +    find_internal(seq(Seq), fun (I) -> I =:= Item end) =/= undefined.
   
   take(Num, Sources) ->
       {seq, {take, Num, seq(Sources)}}.
  
positive.code:         {Item, Enum} ->
              {Item, {append, second, Seq1Enum, Enum}}
      end;
  next({delay, F}) ->
      next(seq(F()));
  next({collect, F, {seq, Enum}}) ->
  
negative.code:             end
      end.
  
  id(X) -> X.
  
  -ifdef(TEST).
  -include_lib("eunit/include/eunit.hrl").
  