anchor.diff:  -export([seed/0, seed/1, seed/2, seed/3, seed0/0, seed0/1,
            uniform/0, uniform/1, uniform_s/1, uniform_s/2]).
   
  +-export([get_algorithm/0, get_algorithm/1]).
  +
   -define(DEFAULT_ALG_HANDLER, as183).
   -define(SEED_DICT, random_seed).
   
  --record(alg, {seed0 :: fun(), seed :: fun(),
  -                uniform :: fun(), uniform_n :: fun()}).
  +-record(alg, {type=?DEFAULT_ALG_HANDLER :: alg(),
  +	      seed0 :: fun(), seed :: fun(),
  +	      uniform :: fun(), uniform_n :: fun()}).
   
   %% =====================================================================
   %% Types
   %% =====================================================================
  +
  +-opaque(state). %% Implementation state
   
   %% This depends on the algorithm handler function
   -type alg_state() :: any().
  
positive.code: -spec uniform_s(N :: pos_integer(), state()) ->
        {pos_integer(), NewS :: state()}.
  
  uniform_s(N, {Alg = #alg{uniform_n=Uniform}, AS0}) 
    when is_integer(N), N >= 1 ->
      {X, AS} = Uniform(N, AS0),
      {X, {Alg, AS}}.
  
  
  %% Setup alg record
  mk_alg(as183) ->  %% DEFAULT_ALG_HANDLER
      #alg{seed0=fun as183_seed0/0, seed=fun as183_seed/1, 
  	 uniform=fun as183_uniform/1, uniform_n=fun as183_uniform/2};
  mk_alg(exs64) -> 
      #alg{seed0=fun exs64_seed0/0, seed=fun exs64_seed/1, 
  	 uniform=fun exs64_uniform/1, uniform_n=fun exs64_uniform/2};
  mk_alg(exsplus) -> 
      #alg{seed0=fun exsplus_seed0/0, seed=fun exsplus_seed/1, 
  	 uniform=fun exsplus_uniform/1, uniform_n=fun exsplus_uniform/2};
  mk_alg(exs1024) -> 
      #alg{seed0=fun exs1024_seed0/0, seed=fun exs1024_seed/1, 
  	 uniform=fun exs1024_uniform/1, uniform_n=fun exs1024_uniform/2};
  mk_alg(sfmt) -> 
      #alg{seed0=fun sfmt_seed0/0, seed=fun sfmt_seed/1, 
  	 uniform=fun sfmt_uniform/1, uniform_n=fun sfmt_uniform/2};
  mk_alg(tinymt) -> 
      #alg{seed0=fun tinymt_seed0/0, seed=fun tinymt_seed/1, 
  	 uniform=fun tinymt_uniform/1, uniform_n=fun tinymt_uniform/2}.
  
  
  
negative.code: %% seed0/1: returns the default state
  %% for the given algorithm handler name in atom.
  %% usage example: seed0(exs64)
  
  -spec seed0(alg()) -> state().
  
  seed0(Alg0) ->
      Alg = #alg{seed0=Seed0} = mk_alg(Alg0),
      {Alg, Seed0()}.
  
  %% seed/0: seeds RNG with default (fixed) state values and the algorithm handler
  %% in the process dictionary, and returns the old state.
  
  -spec seed() -> undefined | state().
  
  