Skip to content

Instantly share code, notes, and snippets.

@moskytw
Last active April 25, 2019 00:35
Show Gist options
  • Save moskytw/70d25b2d05049e5bf10e32e163add181 to your computer and use it in GitHub Desktop.
Save moskytw/70d25b2d05049e5bf10e32e163add181 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from math import log
import funcy as fy
def f(x):
return x
def log_transform_func(base, f):
@fy.wraps(f)
def wrapped_f(*args, **kwargs):
return log(f(*args, **kwargs), base)
return wrapped_f
log_transform_deco = fy.autocurry(log_transform_func)
@log_transform_deco(10)
def g(x):
return x
if __name__ == '__main__':
assert log_transform_func(10, f)(100) == 2
assert log_transform_deco(10)(f)(100) == 2
assert g(100) == 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment