FunctionsFTW/Truth-machine

From Esolang
Jump to navigation Jump to search
setStr("input", input());               "Get input";
if(eqStr(getStr("input"), "0")), () {   "If input is 0";
  print("0");                             "Print 0";
}, () {
  if(eqStr(getStr("input"), "1"), () {  "If input is 1";
    label("l");
    print("1\n");                         "Print 1";
    goto("l");                            "Repeat";
  }, () {});
});

Minimized (140 bytes)

setStr("i",input());if(eqStr(getStr("i"),"0")),(){print("0");},(){if(eqStr(getStr("i"),"1"),(){label("l");print("1\n");goto("l");},(){});});