Created
August 3, 2021 12:37
-
-
Save lyxal/3263975adfea7a41d2805fa19e01056a to your computer and use it in GitHub Desktop.
Testing the implicits library (works well btw)
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 implicits import implicits | |
@implicits("ctx") | |
def pop(stack, n=1, *, ctx): | |
ret = [stack.pop() for i in range(n)] | |
if ctx.reverse_arguments: ret = ret[::-1] | |
return ret |
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
# Simulate main.py | |
from implicits import implicits | |
import elements | |
class Context: | |
def __init__(self): | |
self.reverse_arguments = False | |
ctx = Context() | |
ctx.reverse_arguments = False | |
lst = [1, 2, 3, 4] | |
print(lst) | |
x = elements.pop(lst, 2) | |
print(x, lst) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment