Created
June 4, 2019 19:17
-
-
Save sklam/24b3c4ca2f839cc7bf2e48d72a488e1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numba import njit | |
@njit | |
def foo(functor, a, b): | |
return bar(functor, functor(a, b), b) | |
@njit | |
def bar(functor, a, b): | |
return functor(a, b) | |
# First functor | |
@njit | |
def add(x, y): | |
return x + y | |
r = foo(add, 1, 2) | |
print(r) | |
# Second functor | |
@njit | |
def mult(x, y): | |
return x * y | |
r = foo(mult, 1, 2) | |
print(r) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment