anchor.diff:  
   -module(trinary).
   
  --compile(export_all).
  +-export([from_integer/1, from_trits/1, from_trytes/1, from_text/1, to_text/1]).
   
   -define(CHARSET, <<"9ABCDEFGHIJKLMNOPQRSTUVWXYZ">>).
   
  
positive.code: 	from_trits(Trits0, <<>>).
  
  from_trits([T0, T1, T2|T], Acc) ->
  	Index =
  		case T0 * 9 + T1 * 3 + T2 of
  		I when I < 0 ->
  			27 - abs(I);
  		I ->
  			I
  		end,
  	X = binary:at(?CHARSET, Index),
  	from_trits(T, <<X, Acc/binary>>);
  from_trits([], Acc) ->
  	Acc.
  
  
  pad(Trits) ->
  	case length(Trits) rem 3 of
  	2 ->
  		[0|Trits];
  	1 ->
  		[0, 0|Trits];
  	0 ->
  		Trits
  	end.
  
  
  from_trytes(Trytes) ->
  	from_trytes(Trytes, <<>>).
  
  from_trytes([H|T], Acc) when H >= 0 ->
  	X = binary:at(?CHARSET, H),
  	from_trytes(T, <<Acc/binary, X>>);
  from_trytes([H|T], Acc) when H < 0 ->
  	X = binary:at(?CHARSET, H + 27),
  	from_trytes(T, <<Acc/binary, X>>);
  from_trytes([], Acc) ->
  	Acc.
  
  
negative.code: 	Acc.
  
  
  to_text(Trytes) ->
  	to_text(Trytes, <<>>).
  
  