MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / log_sum

Function log_sum

example_code/item_039.py:54–56  ·  view source on GitHub ↗
(log_total, value)

Source from the content-addressed store, hash-verified

52import functools
53
54def log_sum(log_total, value):
55 log_value = math.log(value)
56 return log_total + log_value
57
58result = functools.reduce(log_sum, [10, 20, 40], 0)
59print(math.exp(result))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected