Fun with Erlang (was Re: Stand Alone Erlang for Windows. yet again)

Ulf Wiger <>
Sat Mar 17 12:04:28 CET 2001


On Sat, 17 Mar 2001, Ulf Wiger wrote:

>I tend to prefer to generate a globally unique ID whenever I need a
>reference. The scheme I prefer is 
>
>  ID = {node(), erlang:now()}. 
>
>It's fast, and under most realistic circumstances (even persistently)
>unique with very high probability.

It's actually also quite easy to produce a nice external ID this way:

()2> F=fun() -> N=node(),{MS,S,US} = erlang:now(),
atom_to_list(N) ++ "." ++ integer_to_list(MS) ++ "." ++
integer_to_list(S) ++ "." ++ integer_to_list(US) end.
#Fun<erl_eval.20.95849314>
()3> F().
""
()4> F().
""
()5> 

/Uffe
-- 
Ulf Wiger                                    tfn: +46  8 719 81 95
Senior System Architect                      mob: +46 70 519 81 95
Strategic Product & System Management    ATM Multiservice Networks
Data Backbone & Optical Services Division      Ericsson Telecom AB




More information about the erlang-questions mailing list