And
The And programming language is a very peculiar esoteric language by User:Rdococ.
Structure
And takes advantage of lazy evaluation so that you can do this:
((x < 3 || y > 2 || z[3] = 1) && input = 'a') && (x := y + 1 && y := 0 && print "Hello guys!")
In that snippet of And code, if x < 3 or y > 2 or the fourth entry of z = 1, and your input is the letter a, then x will become y + 1 and y will become 0, and then the user will see the words, "Hello guys!", and then the instruction pointer will return to the top, asking for another input. The reason this stuff happens is because of lazy evaluation - which allows a chain of and operators like that to work like a conditional.
And code is essentially lines upon lines of chained && and || operations that are repeatedly evaluated over and over again, asking the user for input every time. Who needs conditionals?!
Oh and a few more things. The exit statement - when evaluated - will end the program. The print statement - when evaluated - will print a message. And stuff like assignment and printing always return true.
Computational class
And is Turing complete.
Proof
The following program interprets a BF program (reading the program on the first line of input):
state = 0 && ( input != '\n' && code[rp] := input && rp := rp + 1 || state := 1 ) || state = 1 && ( code[ip] = '+' && data[dp] := (data[dp] + 1) % 256 && ip := ip + 1 || code[ip] = '-' && data[dp] := (data[dp] + 255) % 256 && ip := ip + 1 || code[ip] = '>' && dp := dp + 1 && ip := ip + 1 || code[ip] = '<' && dp := dp - 1 && ip := ip + 1 || code[ip] = ',' && data[dp] := (input % 256 + 256) % 256 && ip := ip + 1 || code[ip] = '.' && print data[dp] && ip := ip + 1 || code[ip] = '[' && ( data[dp] = 0 && state := 2 || ip := ip + 1 ) || code[ip] = ']' && state := 3 || code[ip] = 0 && exit || ip := ip + 1 ) || state = 2 && ( code[ip] = '[' && depth := depth + 1 || code[ip] = ']' && depth := depth - 1 || true ) && ip := ip + 1 && depth = 0 && state := 1 || state = 3 && ( code[ip] = ']' && depth := depth + 1 || code[ip] = '[' && depth := depth - 1 || true ) && ip := ip - 1 && depth = 0 && ip := ip + 1 && state := 1
Examples
Hello World
print "Hello World!" && exit
Cat program
This is a bit restricted because the user can only input one character at a time.
print input
99 bottles of beer
This version adds a new line every time it is evaluated. It goes from 99 to 0 and then repeats, and it handles grammar correctly.
s = 0 && (n := 99 && s := 1) || ( (n = 0 && (print "No more bottles of beer on the wall, no more bottles of beer. Go to the store and buy some more, 99 bottles of beer on the wall." && n := 99)) || (n = 1 && (print "One bottle of beer on the wall. One bottle of beer. Take one down and pass it around, no more bottles of beer on the wall." && n := n - 1)) || (n = 2 && (print "Two bottles of beer on the wall. Two bottles of beer. Take one down and pass it around, one bottle of beer on the wall." && n := n - 1)) || (n > 2 && (print n + " bottles of beer on the wall. " + n + " bottles of beer. Take one down and pass it around, " + (n - 1) + " bottles of beer on the wall." && n := n - 1)))