anchor.diff:  %% do this in a computationally cheap manner.
   
   %% Algorithm: we have a certain capacity of samples in sample_data,
  -%% ?N_SAMPLES. When it is filled, we throw every other away.
  -%% From then, we put only every other incoming sample in the list.
  -%% When sample_data is filled again, we again throw every other away.
  -%% From then, only every fourth incoming sample is put in the list,
  -%% etc.
  -
  --define(N_SAMPLES, 16).
  +%% configurable with the option 'samples'. When this buffer is filled,
  +%% we throw every other element away.  From then on, we put only every
  +%% other incoming sample in the list.  When sample_data is filled
  +%% again, we again throw every other away.  From then on, only every
  +%% fourth incoming sample is put in the list, etc.
   
   sample_data(Data) ->
  -    {0, 1, 1, [Data]}. % divisor, n_received, size, sample_data
  -
  -sample_data(_Data, {Div, N, Size, Samples}) when (N+1) band Div =/= 0 ->
  -    {Div, N+1, Size, Samples};
  -sample_data(_Data, {Div, N, Size, Samples}) when Size =:= ?N_SAMPLES ->
  -    {Div bsl 1 + 1, N+1, Size bsr 1, drop2(Samples)};
  -sample_data(Data, {Div, N, Size, Samples}) ->
  -    {Div, N+1, Size+1, [Data|Samples]}.
  +    %% divisor, n_received, size, capacity, sample_data
  +    {0, 1, 1, getopt(samples), [Data]}.
  +
  +sample_data(_Data, {Div, N, Size, Cap, Samples}) when (N+1) band Div =/= 0 ->
  +    {Div, N+1, Size, Cap, Samples};
  +sample_data(_Data, {Div, N, Size, Cap, Samples}) when Size =:= Cap ->
  +    {Div bsl 1 + 1, N+1, Size bsr 1, Cap, drop2(Samples)};
  +sample_data(Data, {Div, N, Size, Cap, Samples}) ->
  +    {Div, N+1, Size+1, Cap, [Data|Samples]}.
   
   drop2(L) -> drop2(L, false, []).
   
  
positive.code:     ?assertEqual([1, 3, 5], drop2([1, 2, 3, 4, 5, 6])).
  
  sample_data_test() ->
      SD0 = sample_data(1),
      SD1 = lists:foldl(fun sample_data/2, SD0, lists:seq(2, 16)),
      ?assertEqual({0,16,16,[16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1]}, SD1),
      SD2 = lists:foldl(fun sample_data/2, SD1, lists:seq(17, 32)),
      ?assertEqual({1,32,16,[32,30,28,26,24,22,20,18,16,14,12,10,8,6,4,2]}, SD2),
      SD3 = lists:foldl(fun sample_data/2, SD2, lists:seq(33, 64)),
      ?assertEqual({3,64,16,[64,60,56,52,48,44,40,36,32,28,24,20,16,12,8,4]}, SD3),
      SD4 = lists:foldl(fun sample_data/2, SD3, lists:seq(65, 128)),
      ?assertEqual({7,128,16,[128,120,112,104,96,88,80,72,64,56,48,40,32,24,16,8]}, SD4).
  
  alma_test() ->
      L = [ 515093038992664081
  
negative.code:     end.
  
  %% getter for individual options handling defaults and special cases;
  %% see table in opts() above
  getopt(Opt) ->
      case proplists:get_value(Opt, getopts()) of
          undefined -> element(2, lists:keyfind(Opt, 1, opts()));
          true      -> element(3, lists:keyfind(Opt, 1, opts()));
          Value     -> Value
      end.
  
  