Inse

From Esolang
Jump to navigation Jump to search

Inse is an esoteric programming language where code can be stored in memory as strings and can be run later. Its syntax is similar to BASIC where a command is followed by a space and then the arguments. Inse commands end with a period.

There are no variables in Inse, as values are stored directly in memory addresses.

Control flow is handled by multiplying strings in Inse. If a string is multiplied by 0, then it will return nothing, if by a positive number, the string is repeated that many times, and if by a negative number, the commands in the string are reversed. This makes it possible to have different behavior occur based on the sign of a number.

Here is an example of a 99 bottles of beer program

# address 0 is bottles #
set /99/ &0&.
# main loop of the program #
set [
 out &0&.
 out [ bottles of beer on the wall \n].
 out &0&.
 out [ bottles of beer\n].
 out [take one down, pass it around\n].
 # subtraction #
 sub &0& /1/ &0&.
 out &0&.
 out [ bottles of beer on the wall \n \n].
 # test to see whether we are at 0 #
 # sign function will return 1 if we are not at 0, and 0 if we are (it will also turn negative if beer is negative but it should never be)#
 sgn &0& &1&.
 # multiply ourselves by the signed number, if we are 0, it will delete ourselves, it not nothing will happen #
 mul &10& &1& &10&.
 run &10&.
] &10&. # main loop is at address 10 #
run &10&.
dun.

See below for more information on the Language

External Resources