Attached

From Esolang
Jump to navigation Jump to search

Attached is an esoteric programming language by User:Yayimhere, to create a more unique Combinator calculus. Attached gets its name from two things. First it describes the main command and two, I can now attach it to any other documentation as "Attached Documentation".

Combinators

Attached is based on top of the JI combinator set:

I x y = x y;
J x y z w = x y (x w z);

However it has one other combinator, that is majorly more powerful. This combinator is . It applies to both the code it is applied to, and the code that is applied to it. Let's call the former T1 and the latter T2. Note that T1 and T2 are contained to brackets(so in JI(JIJ→IJ)IJ, T1 is IJ, and T2 is JIJ). Then we identify T1 and T2's application trees. Say for an expression J(JI)(I(J)(J)) the application tree is:

    J
   / \
  J   I
 /   / \
I   J   J

As you can see, for any node, its children are all its inputs. Note that for x→y its application tree is:

  →
 / \
x   y

As so T1 is the y subsection, and T2 is the x subsection. Now, → creates a new application tree(and as such expression), where all leaves(nodes without children) of T1 are replaced with the tree T2, and a second tree is made where T1 replaces all the leaves of T2, and then these two trees are joined by a I applying to their parent node. The result then replaces the whole x→y expression. So for the expression JIJ→IJ, we get the expression:

I(J(IJ)(IJ))(I(JIJ))

Which is much larger than the original. Note that Attached has a combinator form of , which takes in both inputs in one side. This combinator is defined:

δ x y = (x→y)

This will most likely be preferred by programmers.