An awful programming language.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
Colin Reeder 7b1542e438 Fix hello example 1 рік тому
src Change addition and multiplication to take any number of arguments 1 рік тому
.gitignore Initial commit 3 роки тому
Cargo.toml Initial commit 3 роки тому
README.md Fix hello example 1 рік тому

README.md

Four

An awful programming language

  • Only has three characters, all others are ignored: 4()
  • Operations are contained within parentheses, the first contained expression is the type. e.g. (44(444))
  • () is Nil.

Hello, world!

This is a simple program that outputs “Hello, world!” It's minimally optimized, and could almost certainly be made much smaller.

(4((4444444)(4(444)(((444)44)4(((444)44)44))))((4444444)(4(((444)44)(44444)(44((444)(444)4)))(44((444)44))))(((444)44)((4444444)(4(((444)44)(44444)(44((444)(444)4)))(4444)))((444)(444)4))((4444444)((((444)44)44)(((444)44)4(444444444))(4(44444)((444)44))))((4444444)(4(444444444)(4444)))((4444444)(444444444))((4444444)((((444)44)44)(((444)44)4(444444444))(4(444)((444)44))))((4444444)((((444)44)44)(((444)44)4(444444444))(4(44444)((444)44))))((4444444)((((444)44)44)(((444)44)4(444444444))(4(4444)((444)(444)4))))((4444444)(4(((444)44)(44444)(44((444)(444)4)))(4444)))((4444444)(((444)44)4(4(4444444)((444)44))))((4444444)(4((444)44)(444444444))))

Value Types

Four supports the following data types:

  • Integer: Non-fractional numbers, created using the 4 literal or from various operations.
  • Nil: A type representing nothing, created using the () literal.
  • String: A string of 0 or more Unicode characters, created using “char code to string” and other operations.
  • Function: A callable procedure, created using “function declaration”. Usable as an operation.

List of Operations

ID Operation Description
0 function declaration Takes one expression as a parameter, and returns a callable function form of it. Functions can be used as operations.
1 multiply Takes any number of values and multiplies them, ignoring nils. If passed zero values, returns nil. Strings can be multiplied by integers for repetition.
4 add Takes any number of values and adds or concatenates them, ignoring nils. If passed zero values, returns nil.
8 divide Divides two numbers. If either value is nil, returns nil.
9 character from string Takes a string and an integer, returns the character at the given index in the given string as a string.
12 conditional Takes three values. If the first value is 4, the second is returned, otherwise the third is returned.
16 subtract Subtracts two numbers. If either value is nil, returns nil.
24 char code to string Interprets a number as a Unicode codepoint. Returns a string.
nil get Returns a function parameter by index.