Anti-Array
Jump to navigation
Jump to search
the idea
Anti-Array is a programming language without arrays or stacks.
Instead of either, it allows you to interpret a string as code. This allows you to programmatically create variables.
Example:
variableName = "{var}" loop variableNumber = 0 | variableNumber < 100 | variableNumber ++ | ( asCode ( variableName + variableNumber ) ) = variableNumber } loop variableNumber = 0 | variableNumber < 100 | variableNumber ++ | print ( asCode ( variableName + variableNumber ) ) }
syntax
Each line is made up of tokens. Each token must have a space between adjacent tokens.
tokens
operators:
- assignment: +=, -=, *=, /=, %=, =, --, ++
- comparison: <, >, ==, !=
- math: +, -, *, /, %
- it performs operations from left to right, ignoring order of operations
commands:
- asCode
- interpret the next string (or string variable) as code, not as a string
- if the string contains \n it will be run, but one asCode is executed it will not execute anything else in that line
- userInput
- gets input from the user
- quotes for string
- number for int
- true/false for boolean
- if
- if boolean
- requires } to close the statement
- loop (statement that runs when initialized) | (condition) | (statement that runs at the end of every loop) |
- parentheses are not necessary
- requires } to close the statement
numbers:
- any sequence of pure numbers will be interpreted as an int
- there are no floating-point numbers
strings:
- anything within quotes
- opening quotes: "{
- closing quotes: }"
boolean:
- false or true
other:
- parentheses
- performs operations inside the parentheses first
- premature line breaks
- use | to act as a line break
variables:
- anything that is not one of the above
- does not require a set type
- internal types are boolean, string, and int
- all variables are global
comments:
- there are currently no comments
errors
- some errors are thrown, but if you try to do something invalid like:
2 = 100 102 ++ anti array
it will ignore it
examples
- factorial:
total = 1 factorialNumber = 9 loop x = 1 | x < ( factorialNumber + 1 ) | x ++ | total *= x } print total
- create array-like variables with 1-100 in them then print them
baseVariableName = "{var}" loop x = 1 | x < 101 | x ++ | ( asCode ( baseVariableName + x ) ) = x } loop x = 1 | x < 101 | x ++ | print ( asCode ( baseVariableName + x ) ) }
- count from 1-99 with asCode
x = "{loop count = 0 | count < 100 | count ++ |\nprint count\n}}" asCode x
- factorial as a function-like
factorial = "{factorialNumber = "{unset}"\nloop countToTwo = 1 | countToTwo < 3 | countToTwo ++ |\nif ( factorialNumber != "{unset}" )\ntotal = 1\nloop x = 1 | x < ( factorialNumber + 1 ) | x ++ |\ntotal *= x\n}\nprint total\n}\nfactorialNumber = }" asCode ( factorial + ( "{10\n}}" ) )