How to resolve the algorithm Execute Brain step by step in the Potion programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Execute Brain step by step in the Potion programming language

Table of Contents

Problem Statement

RCBF is a set of Brainf*** compilers and interpreters written for Rosetta Code in a variety of languages. Below are links to each of the versions of RCBF. An implementation need only properly implement the following instructions: Any cell size is allowed,   EOF   (End-O-File)   support is optional, as is whether you have bounded or unbounded memory.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Execute Brain step by step in the Potion programming language

Source code in the brainfuc programming language

# Where `code` is a string.
bf = (code) :
   tape = (0)
   tape_pos = 0
   brackets = ()
   i = -1
   while (++i < code length) :
      if (code(i) == ">"): if (++tape_pos == tape length): tape append(0)..
      elsif (code(i) == "<"): tape_pos--.
      elsif (code(i) == "+"): tape(tape_pos) = tape(tape_pos) + 1.
      elsif (code(i) == "-"): tape(tape_pos) = tape(tape_pos) - 1.
      elsif (code(i) == "."): tape(tape_pos) chr print.
      elsif (code(i) == ","): tape(tape_pos) = read at(0) ord.
      elsif (code(i) == "["): brackets push(i).
      elsif (code(i) == "]") :
         if (tape(tape_pos) == 0): brackets pop.
         else: i = brackets(-1).
      .
   .
.


  

You may also check:How to resolve the algorithm UTF-8 encode and decode step by step in the Sidef programming language
You may also check:How to resolve the algorithm Greatest common divisor step by step in the Factor programming language
You may also check:How to resolve the algorithm Inheritance/Multiple step by step in the M2000 Interpreter programming language
You may also check:How to resolve the algorithm Date manipulation step by step in the Run BASIC programming language
You may also check:How to resolve the algorithm Dot product step by step in the Befunge 93 programming language