Fucktion

From Esolang
Jump to navigation Jump to search

Fucktion is an esolang created by islptng.

Intro

We have only parenthesis. Other characters are considered as comments.
Each program are computed by calling function f(). Arguments are passed without punctuation or spaces.
Example:

(()(())(()()))

Calls:

f(f(),f(f()),f(f(),f()))

Depending on the number of arguments, f() performs differently.

We have a dictionary to store variables. Like some of my other esolangs, numbers are fractions.
Writting to variable infinity causes a character to be printed to stdout, and reading from it returnes a character from stdin.

f()

No. of args Meaning
0 Evaluates to 1.
1 Evaluates to variable[arg1].
2 Sets variable[arg1] to arg2. Evaluates to arg2.
3 Evaluates to arg1/arg2-arg3.
4+
j = lambda a,b,c: (a<=b + b<=c + a<=c) % 2
cnt = 0
while j(arg1,arg2,arg3):
    for i in args[3:]: evaluate(i)
    cnt += 1
return cnt

Fucktion Generator

Try it online! (might be optimized)

The input should be a Python expression, or multiple separated by commas. Defined primary functions and constants:

Function/constant name Meaning
num(int) Evaluates to the number.
add(a,b) / sub(a,b) / mul(a,b) / div(a,b) Calculations.
setvar(a,b) Set variable.
getvar(a) Get variable.
out(a) / inp() Character I/O.
loop(a,b,c,code...) While loop. Code is a simple expression or multiple separated by spaces.

Examples

Given Python expressions; Enter the code on the constructor to get Fucktion code.

Cat program

Do not stop on EOF.

loop(num(-1),num(0),num(1),out(inp()))

Hello World

"".join([out(num(ord(i)))for i in"Hello, world!\n"])

Implementation

Try it online!