Skip to content

Instantly share code, notes, and snippets.

@JoshCheek
Created April 19, 2015 20:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshCheek/eb22f9e91b9a7891ffea to your computer and use it in GitHub Desktop.
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.
# 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