Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Spexy had a repl, for testing purposes. The >>>> lines are my input, the --> lines are spexy letting me see the Python code it created from my input, and then following that is the result of the evaluation if any.
[siege@maybe src]$ python spexy.py
>>>> (defun make_pair ()
(letrec ((value None)
(getter (lambda () value))
(setter (lambda (v) (setf value v))))
(make-list getter setter)))
--> globals().__setitem__('make_pair', (lambda : ((lambda value, getter, setter: ((value.__setitem__(0, None), getter.__setitem__(0, (lambda : value[0])), setter.__setitem__(0, (lambda v: value.__setitem__(0, v))),)[-1], [getter[0], setter[0],],)[-1])([None], [None], [None]))))
>>>> (letrec ((gs (make_pair)))
(define getter (getf gs 0))
(define setter (getf gs 1)))
--> ((lambda gs: (gs.__setitem__(0, make_pair()), globals().__setitem__('getter', gs[0].__getitem__(0)), globals().__setitem__('setter', gs[0].__getitem__(1)),)[-1])([None]))
>>>> (getter)
--> getter()
>>>> getter
--> getter
<function <lambda> at 0xb76c0df4>
>>>> setter
--> setter
<function <lambda> at 0xb76c0e2c>
>>>> (setter)
--> setter()
## <lambda>() takes exactly 1 argument (0 given)
>>>> (setter "hello world")
--> setter("hello world")
>>>> (getter)
--> getter()
'hello world'
>>>> (getter)
--> getter()
'hello world'
>>>> (setter "919")
--> setter("919")
>>>> (getter)
--> getter()
'919'
@obriencj

This comment has been minimized.

Copy link
Owner Author

obriencj commented Jan 24, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.