C flat --
Jump to navigation
Jump to search
C flat --, or C♭--, is an esolang created by User:Coder07 that is entirely composed of functions and values (e.g. "Hello world", 12345). It has nothing to do with C Flat.
Syntax
Values are strings and numbers. There are also other value types that can be created through functions. Functions work how you'd expect, the function name followed by the arguments in parentheses, separated by commas. Parameters surrounded by parentheses are optional, and ones ending in an asterisk (*)
Function name | Parameters | Description |
---|---|---|
add, sub, mul, div | a, b | Adds/subtracts/multiplies/divides a and b |
if | condition, function, (else) | Runs function if condition is 1, otherwise runs else |
input | (prompt) | Prompts the user for text input |
output | value | Adds value to the output |
key | (character) | Returns if key character is held, or the list of all held keys (as strings) |
list | items* | Creates a list with items |
index | index, list | Gets item index of list |
find | value, list | Finds the first occurrence of value in list |
setindex | index, value, list | Returns list with item index replaced with value |
setvar | var, value | Sets var to value (If the variable is set to a function, it can be called like you'd expect) |
getvar | var | Returns the value stored in var |
function | parameters, code | Creates an anonymous function (parameters should be a list and code should be a string) |
less, equal, greater | a, b | Returns 1 if a is less than/equal to/greater than b, otherwise returns 0 |
and, or | a, b | Returns if a and/or b are equal to 1 |
number, string | value | Coverts value to a number/string |
char | value | Converts a number to its Unicode character. If value is a list of numbers, it returns a string with every item in value converted to its Unicode character. |
charnum | value | If value only has one character, then it returns the number of it in Unicode. If it has multiple characters, it returns a list of each character as a number. |
Examples
Hello world
output("Hello world!")
Cat
output(input())
Truth-machine
setvar("iftrue",function(list(),"output(1)iftrue()")) if(number(input()),getvar("iftrue"),function(list(),"output(0)"))
Interpreter
No interpreter is available yet, but I'm working on one.