Erlang uuid
Генерування uuid в ерланзі
Знайшов майже робочий приклад, трохи переробив під себе:
-module(uuid).
-export([
v4/0,
v4_to_string/0,
to_string/1,
get_parts/1
]).
-import(random).
v4() ->
v4(random:uniform(round(math:pow(2, 48))) - 1,
random:uniform(round(math:pow(2, 12))) - 1,
random:uniform(round(math:pow(2, 32))) - 1,
random:uniform(round(math:pow(2, 30))) - 1
).
v4(R1, R2, R3, R4) ->
<>.
to_string(U) ->
lists:flatten(io_lib:format(
"~8.16.0b-~4.16.0b-~4.16.0b-~2.16.0b~2.16.0b-~12.16.0b",
get_parts(U)
)).
v4_to_string() ->
to_string(v4()).
get_parts(<>) ->
[TL, TM, THV, CSR, CSL, N].
http://github.com/travis/erlang-uuid
Читайте також:
- Random shuffle in erlang
- kerl - easy building and installing of Erlang/OTP instances
- Agner: a repository of libraries and applications
- QR-code erlang library
- Erlang: Hello World
- Python and lists:flatten. Such as in Erlang
- flash socket policy-file-request in Erlang
- URL encode in Erlang
- Erlang: convert any string to binary utf8
- Tutorial: Developing in Erlang with Webmachine, ErlyDTL, and Riak