Skip to main content
Post Made Community Wiki by Dennis
added 1785 characters in body
Source Link
PhiNotPi
  • 29.1k
  • 10
  • 85
  • 157

Length 12 Snippet

1_'[3:~2@+]`

This prints the Nth Fibonacci number. New commands here are :, ~, and @. The : operator creates copies of the top item on the main stack. It's top argument, the 3 in this example, determines the number of copies. So, 0: is the same as #, 1: is a co=op, 2: makes one additional copy for a total of 2, etc.

The ~ is variable reading. Given a string (which can also be a number) as an argument, it returns the value that was previously stored in that variable. In this example, we are reading from a variable (the number we just made copies of) that we never stored anything in. This gives the empty string, which serves as one argument for the next operator. If we simply replaced ~ with 0, then we would have to insert a space between the 0 and the 2.

The @ is stack manipulation. Element only has one operator for rearranging the order of stuff within the stack (as opposed to moving things between stacks, which are ' and "). The first (bottom) argument of @ is the source index, and the second argument is the destination index. In this program, the arguments are 0 (represented by the empty string) and 2, so this operator consumes those numbers, and then moves the 1st thing in the stack to be the 3rd thing in the stack.

1                  push a 1
 _'                take input then move it to the control stack
   [      ]        FOR loop
   [3:    ]        make two additional copies of the top number (3 is the total count)
   [  ~   ]        turn one copy into a zero
   [   2@ ]        move from position 0 to position 2, behind the old number
   [     +]        add the old and newer number
           `       output the result 

Length 12 Snippet

1_'[3:~2@+]`

This prints the Nth Fibonacci number. New commands here are :, ~, and @. The : operator creates copies of the top item on the main stack. It's top argument, the 3 in this example, determines the number of copies. So, 0: is the same as #, 1: is a co=op, 2: makes one additional copy for a total of 2, etc.

The ~ is variable reading. Given a string (which can also be a number) as an argument, it returns the value that was previously stored in that variable. In this example, we are reading from a variable (the number we just made copies of) that we never stored anything in. This gives the empty string, which serves as one argument for the next operator. If we simply replaced ~ with 0, then we would have to insert a space between the 0 and the 2.

The @ is stack manipulation. Element only has one operator for rearranging the order of stuff within the stack (as opposed to moving things between stacks, which are ' and "). The first (bottom) argument of @ is the source index, and the second argument is the destination index. In this program, the arguments are 0 (represented by the empty string) and 2, so this operator consumes those numbers, and then moves the 1st thing in the stack to be the 3rd thing in the stack.

1                  push a 1
 _'                take input then move it to the control stack
   [      ]        FOR loop
   [3:    ]        make two additional copies of the top number (3 is the total count)
   [  ~   ]        turn one copy into a zero
   [   2@ ]        move from position 0 to position 2, behind the old number
   [     +]        add the old and newer number
           `       output the result 
added 468 characters in body
Source Link
PhiNotPi
  • 29.1k
  • 10
  • 85
  • 157

Length 51 Snippet

_'[_]#

This code reads a line with a number as input and then reads that number of additional lines. This can useful is some golf challenges.

The square brackets form# operator removes and destroys a FOR block, which also doubles to serve as the language's IF block. FOR blocks look atsingle item from the top value on the control stack and repeat the code inside that number of times. The first line of input is transferred to the controlmain stack with '(the m-stack or arithmetic stack). Element can be rather heavy with the apostrophes/quotation marks/backticks sometimes When standing alone, this doesn't do anything at all.

Length 42 Snippet

_2^`_`

This is a "cat" program, or a program that squares theoutputs its input and prints the result. The ^_ is a operator which performs exponentiation. Since this is stack-based, the 2 must be pushedgets a line from STDIN and puts it on the main stack before the ^ is performed. The ^` is just one ofoperator (a backtick) removes the many basic arithmetic operations possible, such as addition or modulo. All arithmetic takes place ontop item from the main stack and prints it to STDOUT.

Length 24 Snippet

_`_2^`

This is a "cat" program, or a program that outputs itssquares the input and prints the result. The _^ operator getsis a line from STDIN and puts itoperator which performs exponentiation. Since this is stack-based, the 2 must be pushed on the main stack before the ^ is performed. The `^ operator (a backtick) removesis just one of the top item frommany basic arithmetic operations possible, such as addition or modulo. All arithmetic takes place on the main stack and prints it to STDOUT.

Length 15 Snippet

#_'[_]

This code reads a line with a number as input and then reads that number of additional lines. This can useful in some golf challenges.

The square brackets form a FOR block, which also doubles to serve as the language's IF block. FOR blocks look at the top value on the control stack and repeat the code inside that number of times. The first line of input is transferred to the control stack with #' operator removes and destroys. Element can be rather heavy with the apostrophes/quotation marks/backticks sometimes.


Length 7 Snippet

_,1+,#`

This takes a single itemcharacter from input and outputs the top ofcharacter with the main stackcharacter code 1 greater than that. It's like a ROT1 cipher without the rotation. The (the m, is the char<-stack or arithmetic stack)>code operator, which pushes both the number and code value for its input. When standing alone The first occurrence is used to convert to a number, this doesn't do anything at allof the second output is used. IN the second occurrence, the number is discarded with # and the character is outputed.

Length 5 Snippet

_'[_]

This code reads a line with a number as input and then reads that number of additional lines. This can useful is some golf challenges.

The square brackets form a FOR block, which also doubles to serve as the language's IF block. FOR blocks look at the top value on the control stack and repeat the code inside that number of times. The first line of input is transferred to the control stack with '. Element can be rather heavy with the apostrophes/quotation marks/backticks sometimes.

Length 4 Snippet

_2^`

This is a program that squares the input and prints the result. The ^ is a operator which performs exponentiation. Since this is stack-based, the 2 must be pushed on the stack before the ^ is performed. The ^ is just one of the many basic arithmetic operations possible, such as addition or modulo. All arithmetic takes place on the main stack.

Length 2 Snippet

_`

This is a "cat" program, or a program that outputs its input. The _ operator gets a line from STDIN and puts it on the main stack. The ` operator (a backtick) removes the top item from the main stack and prints it to STDOUT.

Length 1 Snippet

#

The # operator removes and destroys a single item from the top of the main stack (the m-stack or arithmetic stack). When standing alone, this doesn't do anything at all.

Length 1 Snippet

#

The # operator removes and destroys a single item from the top of the main stack (the m-stack or arithmetic stack). When standing alone, this doesn't do anything at all.

Length 2 Snippet

_`

This is a "cat" program, or a program that outputs its input. The _ operator gets a line from STDIN and puts it on the main stack. The ` operator (a backtick) removes the top item from the main stack and prints it to STDOUT.

Length 4 Snippet

_2^`

This is a program that squares the input and prints the result. The ^ is a operator which performs exponentiation. Since this is stack-based, the 2 must be pushed on the stack before the ^ is performed. The ^ is just one of the many basic arithmetic operations possible, such as addition or modulo. All arithmetic takes place on the main stack.

Length 5 Snippet

_'[_]

This code reads a line with a number as input and then reads that number of additional lines. This can useful in some golf challenges.

The square brackets form a FOR block, which also doubles to serve as the language's IF block. FOR blocks look at the top value on the control stack and repeat the code inside that number of times. The first line of input is transferred to the control stack with '. Element can be rather heavy with the apostrophes/quotation marks/backticks sometimes.


Length 7 Snippet

_,1+,#`

This takes a character from input and outputs the character with the character code 1 greater than that. It's like a ROT1 cipher without the rotation. The , is the char<->code operator, which pushes both the number and code value for its input. The first occurrence is used to convert to a number, of the second output is used. IN the second occurrence, the number is discarded with # and the character is outputed.

added 539 characters in body
Source Link
PhiNotPi
  • 29.1k
  • 10
  • 85
  • 157

Element

This is a language that I invented in early 2012 to be a simple golfing language. By this, I mean that there is very little to no operator overloading. The operators are also simpler and fewer in number (all single characters) than most modern golfing languages.

You can find the current version of the Element interpreter, written in Perl, right here.

The most interesting features of this language are its data structures. There are two stacks and a hash that are used to store information. One stack is used mainly for arithmetic, while the other is used mainly for logic. The hash is used to store "variables." The use of a hash means that the number of variables can be practically unbounded.


Length 5 Snippet

_'[_]

This code reads a line with a number as input and then reads that number of additional lines. This can useful is some golf challenges.

The square brackets form a FOR block, which also doubles to serve as the language's IF block. FOR blocks look at the top value on the control stack and repeat the code inside that number of times. The first line of input is transferred to the control stack with '. Element can be rather heavy with the apostrophes/quotation marks/backticks sometimes.


Length 4 Snippet

_2^`

This is a program that squares the input and prints the result. The ^ is a operator which performs exponentiation. Since this is stack-based, the 2 must be pushed on the stack before the ^ is performed. The ^ is just one of the many basic arithmetic operations possible, such as addition or modulo. All arithmetic takes place on the main stack.


Length 3 Snippet

!{}

This program is an infinite loop. The ! is a logical NOT. The control stack starts empty, logically equivalent to "false," so we must invert it and put a 1 on it. The {} form a while loop. It repeats as long as the top value of the control stack is true (non-zero and non-empty-string). Since the control stack will always have a 1 on top, this repeats forever.


Length 2 Snippet

_`

This is a "cat" program, or a program that outputs its input. The _ operator gets a line from STDIN and puts it on the main stack. The ` operator (a backtick) removes the top item from the main stack and prints it to STDOUT.


Length 1 Snippet

#

The # operator removes and destroys a single item from the top of the main stack (the m-stack or arithmetic stack). When standing alone, this doesn't do anything at all.

Element

This is a language that I invented in early 2012 to be a simple golfing language. By this, I mean that there is very little to no operator overloading. The operators are also simpler and fewer in number (all single characters) than most modern golfing languages.

You can find the current version of the Element interpreter, written in Perl, right here.

The most interesting features of this language are its data structures. There are two stacks and a hash that are used to store information. One stack is used mainly for arithmetic, while the other is used mainly for logic. The hash is used to store "variables." The use of a hash means that the number of variables can be practically unbounded.


Length 4 Snippet

_2^`

This is a program that squares the input and prints the result. The ^ is a operator which performs exponentiation. Since this is stack-based, the 2 must be pushed on the stack before the ^ is performed. The ^ is just one of the many basic arithmetic operations possible, such as addition or modulo. All arithmetic takes place on the main stack.


Length 3 Snippet

!{}

This program is an infinite loop. The ! is a logical NOT. The control stack starts empty, logically equivalent to "false," so we must invert it and put a 1 on it. The {} form a while loop. It repeats as long as the top value of the control stack is true (non-zero and non-empty-string). Since the control stack will always have a 1 on top, this repeats forever.


Length 2 Snippet

_`

This is a "cat" program, or a program that outputs its input. The _ operator gets a line from STDIN and puts it on the main stack. The ` operator (a backtick) removes the top item from the main stack and prints it to STDOUT.


Length 1 Snippet

#

The # operator removes and destroys a single item from the top of the main stack (the m-stack or arithmetic stack). When standing alone, this doesn't do anything at all.

Element

This is a language that I invented in early 2012 to be a simple golfing language. By this, I mean that there is very little to no operator overloading. The operators are also simpler and fewer in number (all single characters) than most modern golfing languages.

You can find the current version of the Element interpreter, written in Perl, right here.

The most interesting features of this language are its data structures. There are two stacks and a hash that are used to store information. One stack is used mainly for arithmetic, while the other is used mainly for logic. The hash is used to store "variables." The use of a hash means that the number of variables can be practically unbounded.


Length 5 Snippet

_'[_]

This code reads a line with a number as input and then reads that number of additional lines. This can useful is some golf challenges.

The square brackets form a FOR block, which also doubles to serve as the language's IF block. FOR blocks look at the top value on the control stack and repeat the code inside that number of times. The first line of input is transferred to the control stack with '. Element can be rather heavy with the apostrophes/quotation marks/backticks sometimes.


Length 4 Snippet

_2^`

This is a program that squares the input and prints the result. The ^ is a operator which performs exponentiation. Since this is stack-based, the 2 must be pushed on the stack before the ^ is performed. The ^ is just one of the many basic arithmetic operations possible, such as addition or modulo. All arithmetic takes place on the main stack.


Length 3 Snippet

!{}

This program is an infinite loop. The ! is a logical NOT. The control stack starts empty, logically equivalent to "false," so we must invert it and put a 1 on it. The {} form a while loop. It repeats as long as the top value of the control stack is true (non-zero and non-empty-string). Since the control stack will always have a 1 on top, this repeats forever.


Length 2 Snippet

_`

This is a "cat" program, or a program that outputs its input. The _ operator gets a line from STDIN and puts it on the main stack. The ` operator (a backtick) removes the top item from the main stack and prints it to STDOUT.


Length 1 Snippet

#

The # operator removes and destroys a single item from the top of the main stack (the m-stack or arithmetic stack). When standing alone, this doesn't do anything at all.

added 396 characters in body
Source Link
PhiNotPi
  • 29.1k
  • 10
  • 85
  • 157
Loading
added 411 characters in body
Source Link
PhiNotPi
  • 29.1k
  • 10
  • 85
  • 157
Loading
added 491 characters in body
Source Link
PhiNotPi
  • 29.1k
  • 10
  • 85
  • 157
Loading
Source Link
PhiNotPi
  • 29.1k
  • 10
  • 85
  • 157
Loading