Asic

From Esolang
Jump to navigation Jump to search

Asic ("ah-sick" /a.sık/) is an esolang created by CreeperBomb in 2023. The name comes from "adic" (as in "5-adic integer") and "sick" (as in cool, not ill). It is many an excuse to show off how cool adic bases, especially the used 5-adic integers, can be.

Numbers

Numbers are all 5-adic integers. To show repeated digits, overlines (via macrons) are used over the repeating numbers. For example, 4̄ is …44444444, 0̄1̄2̄3̄4̄23 is …01234012340123423, and 13̄4̄2 is nonsense (due to how adic numbers work, a digit to the left of infinite digits is simple not a thing). If the only digit repeated is 0, i.e. a number of the form 0̄…XYZ, the 0̄ does not need to be written. For example, the decimal number "12" would be written as "22" as well as "0̄22". Any redundancy, such as "1̄1̄" instead of "1̄" or "1̄2̄1" instead of "2̄1̄", is just as accepted as the "optimal" form.

This notation is also how numbers are printed. An interpreter or complier of Asic may or may not use the "optimal" form of a number when printing.

Commands

Commands are seperated by at least one newline. All other whitespace is ignored unless specified otherwise.

Text & name Description Notes
?{}
Curly-if
?[]
Square-if
If the condition between the ? and { or [ is false, jump to the matching } or ], respectively The conditions are = & , and curly-ifs and square-ifs can go through each other (i.e. things like ?{?[}] are allowed). Newlines are required before and after the body
=
Assignment
Assigns what's on the left to the right If a function is on the left, it should be in the format name(arg1 argr2 arg3 …) and none of the dummy argument names should be variable names (# being unusuable in function & variable names but usuable in argument names is helpful for this). The spaces between argument names is required. If a function when called is prefixed with #, then the function is run digitwise; each digit is put in the function and then the last digit of the result is the digit of the resulting number.
+ - * ^ ÷ % ! & ~
Math/digitwise operations
Adds two numbers, subtracts two numbers, multiplies two numbers, exponentiates two numbers (fractional part is removed), divides two numbers (fractional part is removed), mods two numbers, negates a number, digitwise ands (the last digit of the product of two digits is the and of those digits) two numbers, and digitwise ors (the last digit of the difference of the sum of the digits and the product of the digits is the or of those digits) a number The biargumented operations are surronded by parenthesis (unless the least nested, like in x = 2 + x) and go between their arguments, while the monoargumented operations don't require parenthesis anytime and go before their argument
input x Input
print x Ouput
Sets x to user input and prints x, respectively I/O is only numerical.
i e pi/π
Constants
Put next to a number, is equal to the respective constant times that number. Otherwise, it is simply equal to that constant Since i is a 5-adic integer, it is possible for all multiples to be represented prefectly. The others, however, get their fractional part removed to make them integers (done after the multiplication, so e+e is 4 while 2e is 5)
(| |) (|| ||)
Absolute value
Takes the absolute value of what's inside The single-pipe one is the complex absolute value while the double-pipe one is the 5-adic absolute value
(x, y, z, …)
Lists
When doing assignment, math, & condition-checking, all the choices must result in truth. In other words, you replace a command with a list with duplicates of a command, each with a unique combination is done In each of the combination, if a variable or function is a list, then in each combination for a command the item is the same across repeated mentions of that variable or function unless precended by $. For example, for var=(1,2), var=var is true while $var=$var may be true or false

Loops are done via recursion.

Example programs

"Truth machine":

input x
print !x

Actual truth machine:

input v
print v
truth(v)
truth(x) =
?x=1[
print x
truth(x)
]

1 if negative, 0 elsewhere:

input x
print ((0^(|(|x|)+x|))-(0^(|x|)))

Set x to a list of every 5-adic integer:

f(#x)=(0,1,2,3,4)
x=#f(0)