Disfunction

From Esolang
Jump to navigation Jump to search

Disfunction is a esolang that works using only functions.

Commands:

Command Description
while(n,m):code run code while n≠m
print(x) print x
func f = code create function f(args), can take a function as input
arg<n> nth argument
delete when activated, delete the command with this value as an argument (expand function frist)
activate(f) activate all delete commands in f
now(n) replace now(n) with whatever value n had when this command was executed
|f| the number of commands in f (arg<n> not counted)
get ask user for number and use that
chose(args) chose random from args
checkpoint(f) NOP
find(n,f) output the code after the nth checkpoint
run(code,f) run code then output f
add(f,n,g) in f add g to the arguments of the command under the nth checkpoint

(Note: \ is an escape character)

Programs

Looping counter

func f = run(print("*"),arg1)
func g = 
while(|f|,|g|):
 f()
 func f = f(run(print("*"),arg1))
 print("\n")

Hello world

print("Hello world")

Cat program

func f = print()
func g =
while(|f|,|g|):
 print(get)

Truth-machine

func f = now(get)
func g = 
print(f())
while(f(),|g|):
 print(f())

Infinite quine:

print("print(\"print(\\\"...