Maybe machine

From Esolang
Jump to navigation Jump to search

a maybe machine is a program that does this:

  • it takes in user input
  • it generates a random number that is either 1 or 0
  • it compares the number and the input
  • if it's true it prints the input forever
  • else it prints the input once

Implementations

><>

i68*->x0v
$:n:v >1>
>:n<>@_=?!;

Lua

x=io.read()print(x)for i=2,1/(x-math.random(0,1))do print(x)end

node.js

a=+prompt()
n=Math.random()<.5?1:0
do{console.log(a)}while(a==n)console.log(a)

Thue

I::=:::
?::=.
?::=!
0.::=~0
1.::=~1
0!::=00.!
1!::=11.!
::=
I?

See also