Created
April 19, 2015 20:39
-
-
Save JoshCheek/eb22f9e91b9a7891ffea to your computer and use it in GitHub Desktop.
Linked List (only as far as the stack) implemented with the constraints of the lambda calculus.
This file contains hidden or 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
# Build the relevant methods | |
-> with_self { | |
-> list { | |
-> the_program { | |
the_program[with_self, list] }}[ | |
# list | |
-> build_node { | |
with_self[-> me { | |
build_node[-> { me }, -> { raise 'too far!' }]}]}[ | |
# build_node | |
with_self[-> build_node { | |
-> get_tail, data { | |
with_self[-> node { | |
-> caller { | |
caller[ | |
-> data { build_node[node, data] }, | |
get_tail, | |
data] }}]}}]]]}[ | |
# with_self | |
-> get_me { | |
-> you { | |
you[-> *arg { | |
get_me[get_me][you][*arg] }]}}[ | |
# get_me | |
-> get_me { | |
-> you { | |
you[-> *arg { | |
get_me[get_me][you][*arg] }]}}]] | |
.(-> with_self, list { | |
# Use the list | |
list.(-> push, * { push['a'] | |
.(-> push, * { push['b'] | |
.(-> push, * { push['c'] | |
})})}) | |
.(-> _, pop, data { data # => "c" | |
pop.(-> _, pop, data { data # => "b" | |
pop.(-> _, pop, data { data # => "a" | |
})})})}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment