Four
		
		
		
		Jump to navigation
		Jump to search
		
| Paradigm(s) | Functional | 
|---|---|
| Designed by | vpzom | 
| Appeared in | 2018 | 
| Computational class | Unknown | 
| Major implementations | https://git.vpzom.click/vpzom/four | 
| File extension(s) | .4 | 
Four is an esoteric, purely functional 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.
Examples
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.
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. |