December 22nd, 2021
Code Reading Club Reading Countdown - 22
Countdown - Snippet 22
Today, a snippet in Erlang submitted by @_eddieantonio (also one of our top code readers!)
% For some odd reason, Erlang doesn't have this builtin: pow(X, Y) when Y < 0 -> 1/pow(X, -Y); pow(X, Y) when is_integer(Y) -> pow_recursive(X, Y, 1). pow_recursive(_, 0, Result) -> Result; pow_recursive(X, Y, Product) -> NextProduct = case Y rem 2 of 0 -> Product; 1 -> X * Product end, pow_recursive(X * X, Y div 2, NextProduct).
What alternative names can you choose for the variables in this snippet?
Submit your answer in our form.