Talk:Formula

From Esolang
Jump to navigation Jump to search

Cat program

I think I might have misunderstood how input works: it seems impossible to correctly handle input in a 1-variable program. Any input instruction has at least one possible input value that either causes an error or terminates the program. Regardless, here is a 2-variable cat program:

1.5 - 0.3*x - 1.5*x^2 - 2.5*y

And, since there isn't an interpreter to run it on, let me step through it manually:

f(0,0) = 1.5    input a bit (say, a 0). Rounded to 1: increment x
f(1,0) = -0.3   output a 0. Rounded to -1: decrement x
f(0,0) = 1.5    input a bit (say, a 1). Rounded to 2: increment y
f(0,1) = -1     Rounded to -1: decrement x
f(-1,1)= -2.2   Rounded to -2: decrement y
f(-1,0)= 0.3    output a 1. Rounded to 1: increment x
f(0,0) = 1.5    et caetera...

Snowyowl (talk) 13:52, 28 February 2013 (UTC)

Some helpful functions

You can define

abs(x) = (x^2)^(1/2)
!(x) = (abs(x^2-1)-x^2+1)/2

These may be helpful for getting exact values at designated spots. --Ørjan (talk) 01:14, 1 March 2013 (UTC)

BTW !(x) only works for 0 and values at least 1 away from 0 (so including all integers). I don't think it is possible to define it to work for real numbers arbitrarily close to 0, because Formula has no basic functions that are well defined in an interval but not continuous everywhere in it, and this is inherited by composed functions. Although I'm a bit confused about the exponentials. --Ørjan (talk) 21:23, 1 March 2013 (UTC)