Skip to content

Instantly share code, notes, and snippets.

@lyxal
Created August 3, 2021 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyxal/3263975adfea7a41d2805fa19e01056a to your computer and use it in GitHub Desktop.
Save lyxal/3263975adfea7a41d2805fa19e01056a to your computer and use it in GitHub Desktop.
Testing the implicits library (works well btw)
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
# 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