Added to Favorites

Popular Searches

Definitions

- See False for other meanings of false.

FALSE is notably more tractable than most esoteric programming languages. The fundamental operations that it provides are reasonably sensible, and there is no gratuitous complexity. In these respects it stands in stark contrast to the behemoths Intercal and Malbolge. The difficulty of programming in FALSE comes mostly from the low level nature of the language, which has the feel of a Forth-like assembly language. The remainder of the language's awkwardness comes from the concise punctuation-based syntax, which many people find more difficult than a more conventional word-based syntax.

The language features basic arithmetic and logical operations, variables, subroutines as lambda calculus expressions, control flow statements, and input/output operations. FALSE operations are done using a stack. Its structure is largely based on the Forth programming language.

`1 3_+`

:
`1`

: pushes the integer 1 onto the stack

`3`

: pushes the integer 3 onto the stack

`_`

: pops 3 from the stack, negates it, and pushes -3

`+`

: pops 1 and -3 from the stack and pushes their sum, -2.

`'`

(single-quote)), 32-bit integers, boolean values (0 representing false; -1 representing true), and lambda calculus expressions. These can be used on the stack or stored in variables.
Arithmetic operators are `+`

, `-`

, `*`

, and `/`

(binary operators, which pop two elements from the stack and push (respectively) their sum, difference, product, or quotient) and the `_`

(underscore) is unary negation (which pops one element and pushes its negation).

Logical operators are `=`

, `>`

`, `

`&`

, `|`

(binary operators of equality, greater than, logical conjunction, and logical disjunction), and `~`

(unary logical negation).

`Stack operators are (with examples of form `

`example input`

→ `resulting stack`

):

`$`

- Duplicates the topmost element of the stack:`0 1$`

→`0 1 1`

`%`

- Deletes the topmost stack element:`0 1%`

→`0`

`- Swaps the two topmost stack elements:`

`0 1 2`

→`0 2 1`

`@`

- Rotates the third stack item to the top:`0 1 2 3@`

→`0 2 3 1`

`ø`

- Pick: Copies the n-th stack item to the top:`7 8 9 2ø`

→`7 8 9 7`

```
```

`Variables`

```
Variables are single lowercase alphabetical characters (a-z). All variables are global.
````:`

(colon) sets a variable to the value at the top of the stack (ie, `3a:`

assigns the value 3 to the variable a) and `;`

(semicolon) reads their values (ie, `a;`

would push 3 onto the stack if a has been assigned 3). The heavy use of the stack in FALSE eliminates a great deal of need for variables, and they are mainly used with subroutines.
## Subroutines

Subroutines are lambda calculus expressions, and are pieces of code contained between `[`

and `]`

. The "apply" operator is `!`

. It takes the lambda calculus expression on top of the stack and runs it. Note that if the value on top of the stack is not a lambda expression, the program will behave abnormally. A very basic example subroutine:

3[1+]!

This pushes 3 on the stack, pushes the expression `[1+]`

(which takes the current stack and increments the top value by 1), and applies this to 3, leaving the stack as 4.
## Control flow

FALSE has two control flow statements, if and while.
### If

The "if" operator is `?`

. It takes the two top stack elements, the top being a lambda expression; the second being a boolean, and runs the lambda expression if the boolean is true. For example,

a;1=[3b:]?

tests if the variable a is equal to 1, and if so, runs the expression `[3b:]`

which assigns 3 to b.
### While

The "while" operator is `#`

. It takes the top two stack elements, both lambda expressions, and continually evaluates the second element, then the top element, until the second one stops returning true (that is, leaving a true boolean on top of the stack). For example,

[a;1=][2f;!]#

runs the expression `[2f;!]`

(which puts 2 on the stack and runs whatever lambda expression is contained in the variable f) for as long as the variable a is equal to 1.
## Strings

Strings are not a real data type in FALSE; they only exist as string literals and cannot be stored directly on the stack nor in variables, and cannot be modified. However, they can be contained within lambda expressions (which can be stored). When a string is encountered it is simply printed as output. Strings are any character sequence between double-quotes (`""`

), including newlines. So, a program consisting simply of
"Hello world!

"

would print "Hello world!" followed by a new line. Lambda expressions can contain strings. For example:

a;1=["true"]?

would print "true" if the variable a is equal to 1.
## Input / Output

Apart from strings, which print themselves, FALSE has a number of operators for input/output from and to standard streams. `.`

(period) prints the topmost stack item out as an integer.
`,`

(comma) prints out the topmost stack item as an ASCII character.
`^`

reads a single character from standard input and pushes it on the stack.
`ß`

flushes both standard input and standard output streams.

## Comments

Comments are delimited by `{`

and `}`

. Comments cannot be nested.
## Code examples

Sample programs taken from the FALSE Programming Language web page:"Hello world!

"

File copy utility. Usage: `copy <infile >outfile`

ß[^$1_=~][,]#

Factorial calculator for numbers 1 through 8:
[$1=~[$1-f;!*]?]f: { fac() in FALSE }

"calculate the factorial of [1..8]: "

ß^ß'0-$$0>~8>|$

"result: "

~[f;!.]?

["illegal input!"]?"

"

Write all prime numbers up to 100:

99 9[1-$][$@$@$@$@/*=[1-$$[%1-$@]?0=[$.' ,]?]?]#

## See also

- Forth programming language, from which the structure of FALSE was derived.
- Esoteric programming language
- Stack-oriented programming language

## External links

```
Wikipedia, the free encyclopedia © 2001-2006 Wikipedia contributors (Disclaimer)
```

This article is licensed under the GNU Free Documentation License.

Last updated on Tuesday October 07, 2008 at 06:41:24 PDT (GMT -0700)

View this article at Wikipedia.org - Edit this article at Wikipedia.org - Donate to the Wikimedia Foundation

```
```

```
```

```
```

```
```

```
```

```
```

```
Copyright © 2014 Dictionary.com, LLC. All rights reserved.
```

```
```

```
```