functional programming - Extract only the number from a ref in erlang -
i'm new erlang. need take number returned make_ref(). so, if make_ref() returns :#ref<0.0.0.441> extract 441.
any idea how this?
try instead:
unique_integer() -> try erlang:unique_integer() catch error:undef -> {ms, s, us} = erlang:now(), (ms*1000000+s)*1000000+us end.
edit: main difference between solution , extracting integer using io_lib:format("~p", [ref])
speed. when solution takes around 40ns in r18, transformation list, regexp , integer takes 9µs. go 2 orders of magnitude faster solution.
Comments
Post a Comment