- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
%% wrapper for math:log/1 to avoid dividing by zero
math_log(0) ->
1;
math_log(0.0) ->
1.0;
math_log(X) when X < 0 ->
0; % it's not possible to take a log of a negative number, return 0
math_log(X) ->
math:log(X).
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
%% wrapper for math:log/1 to avoid dividing by zero
math_log(0) ->
1;
math_log(0.0) ->
1.0;
math_log(X) when X < 0 ->
0; % it's not possible to take a log of a negative number, return 0
math_log(X) ->
math:log(X).
Math, how does it work: https://github.com/folsom-project/bear/commit/6c19d6a2ee031512fca9916dd7cca2fc7ea2a38e
Ну так, весьма отдалённо. В прологе нет возвращаемых значений, т.е. было бы