Skip to content

Instantly share code, notes, and snippets.

%% Power function (X ^ Y) and root function (X ^ (1/Y)) for
%% integers in Erlang
%% by Kenji Rikitake <kenji.rikitake@acm.org> 26-JAN-2010
%% modified by Hynek Vychodil <vychodil.hynek@gmail.com> 2-FEB-2010
%% Distributed under MIT license at the end of the source code.
-module(bignum_root).
-export([power/2, root/2, sqrt/1]).
proplists_get_value(Key, List)->
case lists:keyfind(Key,1,List) of
{K,V} when K =:= Key ->
V;
_->
proplists_get_value_(Key, List)
end.
proplists_get_value_(_,[])->
undefined;
@pichi
pichi / bignum_root.erl
Last active July 24, 2016 20:17 — forked from jj1bdx/bignum_root.erl
Power function (X ^ Y) and root function (X ^ (1/Y)) for integers in Erlang
%% Power function (X ^ Y) and root function (X ^ (1/Y)) for
%% integers in Erlang
%% by Kenji Rikitake <kenji.rikitake@acm.org> 26-JAN-2010
%% modified by Hynek Vychodil <vychodil.hynek@gmail.com> 2-FEB-2010
%% modified by Kenji Rikitake <kenji.rikitake@acm.org> 3-FEB-2010
%% modified by Hynek Vychodil <vychodil.hynek@gmail.com> 24-JUL-2016
%% Distributed under MIT license at the end of the source code.
-module(bignum_root).
@pichi
pichi / test.erl
Last active July 27, 2016 03:25 — forked from zhongwencool/test.erl
Find top n items in a unordered list
-module(test).
-compile(export_all).
%% API
-compile({inline, [ insert/2
, merge/2
]}).
insert(E, []) -> [E];
insert(E, [E2|_] = H) when E =< E2 -> [E, H];
@pichi
pichi / test.erl
Last active July 27, 2016 08:17 — forked from redink/test.erl
Find top n items in a unordered list
-module(test).
-compile(export_all).
%% API
-compile({inline, [ insert/2
, merge/2
]}).
insert(E, []) -> [E];
insert(E, [E2|_] = H) when E =< E2 -> [E, H];