efghij

From Esolang
Jump to navigation Jump to search

efghij (everyday food, garden & home item jenga) is an esoteric programming language invented by User:Timwi in 2016. It uses everyday objects found in kitchens, home offices, garden sheds and bedrooms to express program logic. Despite its appearance, it is not stack-based, though some might say it’s object-oriented.

Overview

The following constructs are defined so far:

  • The object at the bottom of any construct is the function name. The entire function declaration must be balanced on top of it.
  • In functions with a single parameter, the function’s parameter may be identified by sauces.
  • Functions with multiple parameters must declare those parameters by attaching the parameter names to the function name with one or more rubber bands. Further, if the order of the parameters matters, all parameter names except one must carry a disambiguating marker (a clothes peg, a paperclip, a rubber band, a sello tape roll, a hex key, ...).
  • When calling a function, the arguments are balanced on top of the function name. In functions with disambiguated parameters, the arguments must carry the same disambiguating marker.
  • Flat surfaces (plates, casseroles, cutting boards, trays, etc.) may be used to group multiple subconstructs or simply aid in balancing. For example, if a function whose name is a tic tac box requires many parameters, those parameters may be placed on a tray which itself is balanced on top of the tic tac box.
    • If an unmarked flat surface has multiple statements/expressions on it, they are executed from left to right. Note that this implies that the camera position is semantically relevant. If this is undesired, place screws on the flat surface to indicate the order of execution (pointing from earlier to later statement).
  • Flat surfaces can also be used to express loops or conditional constructs:
    • If the surface has a clothing peg attached to it, it’s a for loop. The initial value for the loop variable is identified by a paperclip. The number of iterations is identified by a rubber band.
    • If the surface has a hex key hanging off it, it’s a while loop. The while condition expression can be identified by a paperclip or a rubber band.
    • If the surface has a ping pong ball on it, it’s a ternary conditional. The condition expression is identified by a paperclip. The positive expression is markerless, while the negative expression is identified by an adhesive hook.
    • A surface can have multiple markers on it if it is simultaneously one of these constructs as well as an argument to a multi-parameter function. If the construct is unambiguous, any combination may be used. If it would be ambiguous, it may be necessary to place two surfaces on top of each other and mark the lower surface with the argument marker and the upper surface with the loop/conditional marker.
  • A lone bottle cap or a small piece of cheese has the constant value 1 (one).
  • An audio plug or a number 2 pencil has the constant value −1 (negative one).
  • An empty drinking glass sets a variable to a value (and also returns that value as an expression). The variable name as well as the expression must be balanced on top of the glass. In cases where both arguments are assignable variables, the assignee can be indicated by a paperclip or a rubber band.
  • An upside-down plastic cup performs addition.
  • A stapler performs multiplication.
  • A hammer performs an in-place decrement of a variable (and returns the new value).
  • A toilet roll indicates the function’s return value.
  • A piece of paper prints the name of whatever is on it, or what is written on it.

Example: BelMandel (factorial)

The BelMandel (a.k.a. factorial) function, shown from three different angles. Note that the function name is obscured in two of the three screenshots.

This example demonstrates the BelMandel (Bigness Exactly Like Multiplying All Naturals Deemed Equal or Less than) function (otherwise known as factorial). This demonstrates a single-parameter function declaration in which the parameter is identified by sauces.

In this example, the tray and the cutting board constitute code blocks. The oblong plate, however, has a clothes peg on it, which expresses a for loop. The fork is a local variable.

The fork variable is initialized to 1 within the for loop’s initial-value expression. The sauce with the rubber band indicates that the number of iterations is equal to the function’s argument. The stuff on the cutting board is the loop body. Using a stapler, the fork is multiplied by the sauce and the result assigned to the fork using a drinking glass. A hammer decrements the sauce, which demonstrates that the function’s parameter can be used as a local variable too.

Finally, the toilet roll indicates that the return value is the final value of the fork.

Example: NUSSPLI (Ackermann function)

The NUSSPLI (a.k.a. Ackermann) function, shown from three different angles. Note that the function contains recursive invocations of itself.

This example demonstrates the NUSSPLI (Numerically Useless, Staggeringly, Stupefyingly, Preposterously Large Integers) function (otherwise known as the Ackermann function). It exemplifies a two-parameter function: internally, the parameters are named fork and spoon; externally, the first parameter is markerless and the second parameter is identified by a clothes peg. The function body is a single toilet roll with an expression balanced on top of it.

The tray, having a ping pong ball on it, is a conditional that checks the value of the fork. If this value is zero, the expression with the adhesive hook is returned, which is the addition (upside-down plastic cup) of the spoon and the value 1 (lone bottle cap).

If the fork is non-zero, a recursive call to the NUSSPLI function is performed. The first argument is the upside-down plastic cup which adds −1 to (thus, subtracts 1 from) the fork. The second argument is another conditional. Note that even though the second argument is a flat surface with a clothes peg, it is not a while loop because if it was, the ping pong ball on it would be a syntax error. Therefore, the ping pong ball makes it another ternary conditional and the clothes peg makes it the recursive call’s second argument.

Within this ternary, the condition is the value of the spoon; if it is zero, the result is 1 (lone bottle cap marked with an adhesive hook); otherwise, it is another recursive call whose first argument is the fork and whose second argument is the spoon, decremented by 1 (by adding −1 to it). Note that, since it is not possible to clip the clothes peg onto the upside-down plastic cup, a rubber band can be used to hold it in place. If this rubber band would cause ambiguity, blu-tack can be used as well.

Example: CHUNKY (integer division function)

The CHUNKY (a.k.a. integer divide) function, shown from three different angles.

This example demonstrates the CHUNKY (Counting How Uniform Nodes Knive Yours) function (otherwise known as the integer divide function) by User:BakersDozenBagels. It uses a while loop (the white cutting board) to perform its function.

Example: FANTA (Fibonacci sequence)

The FANTA (a.k.a. Fibonacci) function, shown from two different angles.

This example demonstrates the FANTA (Former And Next Terms Added) function, made by User:JakkOfKlubs. This program outputs the nth number in the Fibonacci sequence, where n is equal to the parameter represented by the hot sauce.

This program contains the base platform being a blue book, and a for loop represented by the red book with a clothes pin attached to it. The number of iterations of the for loop is represented by the hot sauce. Additionally, there are three variables being assigned, being the fork, spoon, and knife.

The leftmost bottom glass has a box on top of it. The second glass on top of this box contains a fork and a block of cheese. The fork, one variable, is being assigned the value of 1 (from the cheese). The spoon, another variable, is also being assigned a value of 1 as a result of the bottom glass assigning the return value of the top glass to the spoon.

The red book (the for loop) first assigns the value of the fork to the knife (with a rubber band), as the knife is the "temp" value, then takes the sum of the fork and the spoon (through the red plastic cup) and assigns it to the fork, and then finally assigns the value of the knife to the spoon (with a rubber band).

After the loop is completed, the toilet paper roll returns the final value of the spoon.

Future extensions

Everybody is invited to enrich the instruction set with new items, as long as you document them here (it’s a wiki!) and upload photos of a reasonable example function that makes use of them.