2

I have this pretty simple program:

+[----->+++<]>.
+[----->+++<]>.

Trying to log two g's
however the output is
how can i make a newline break the code? operator? Not possible?

David Buck
  • 3,752
  • 35
  • 31
  • 35
bruh5000
  • 74
  • 5
  • If you want to print two g's just do as @Keldan Chapman said. If you want to store the g in two positions in the memory (in case you need to delete one of the g's later on for other reasons but still need a duplicate) you can either place a > at the start of your second line so that g is stored at the next position in the memory or use [->+>+<<]>>[-<<+>>]<. This can duplicate any value and position it on the next space in memory but uses up three memory spaces (one for each copy and an additional temporary storage space), so it won't work unless your memory looks like [g, 0, 0] – user17301834 Sep 11 '22 at 15:34

2 Answers2

1

Using . does not reset the value at the current cell, which is why you get Ø instead of g as the second char; because you started with a different value. If you want to output gg then the simplest method would be to merely output twice:

+[----->+++<]>.. -> gg

If you want them to be printed on seperate lines, then you just have to output a newline character (ascii value 10) in between:

+[----->+++<]>.  g
>++++++++++.    \n
<.               g

Resulting in:

g
g
Keldan Chapman
  • 665
  • 5
  • 21
0

Start your code with > to move to 0 then everything should work

>+[----->+++<]>.
>+[----->+++<]>.

See this thread for forther reading.

https://stackoverflow.com/a/36122876/4267015

Naor Tedgi
  • 5,204
  • 3
  • 21
  • 48