We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

IfSetThenSet

From Esolang
(Redirected from Ifsetthenset)
Jump to navigation Jump to search

IfSetThenSet is an minimalistic esolang with only 1 command. The memory contains 8 bits, either 1 or 0, the first bit being 1. If an certain bit is 1 or 0, then it sets another bit to 1 or 0. The format of the command is "[Memory location in binary to check][Value to compare (0/1)][Memory location in binary to set][Value to apply (1/0)]", or something like "00000000". For example, 01010010 means that if the third bit is set to 1 then set the second bit to 0.

Notes

  • "- - - - 0001" (if CONDITION then set bit 1 to 1) sets the second bit to the user's input
  • "- - - - 0000" (if CONDITION then set bit 1 to 0) ouputs the second bit.
  • The command are separated with "-"
  • The program loops when it reaches the finish.

Example programs

  • AND (one time):
00010001-00100101-00010001-00100101-00010010-01000011-00010000
  • OR:
00010001-00110101-00010001-01010011-00010000-00010100
01000001-01100000-00010101-00100111

Interpreters

Interpreter in TurboWarp that requires two new blocks not in Scratch, not including the main loop. View as an image here.

define Setup
delete all of [Memory v]
delete all of [Program v]
delete all of [Output v]
add (1) to [Memory v]
repeat (7)
  add (0) to [Memory v]
end
set [Program v] to (01000001-01100000-00010101-00100111)
set [my variable v] to (0)
repeat ((1) + (count (-) in (Program)))
  change [my variable v] by (1)
  add (item (my variable) of (Program) split by (-)) to [Program v]
end

define Execute (Command)
if <(letter (4) of (Command)) = (item ((1) + (((letter (1) of (Command)) * (4)) + (((letter (2) of (Command)) * (2)) + ((letter (3) of (Command)) * (1))))) of [Memory v])> then
  set [temp v] to ((1) + (((letter (5) of (Command)) * (4)) + (((letter (6) of (Command)) * (2)) + ((letter (7) of (Command)) * (1)))))
  if <(temp) = (1)> then
    if <(letter (8) of (Command)) = (0)> then
      add (item (2) of [Memory v]) to [Output v]
    else
      ask [Binary digit?] and wait
      replace item (2) of [Memory v] with ((answer) mod (2))
    end
  else
    replace item (temp) of [Memory v] with (letter (8) of (Command))
  end
end

Community

If you have made an interesting program in this, edit the page an insert it below this text.