Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

bf.raku

Brainfuck interpretter made just for fun as an excersize for Raku. Don't ask "Why?", because "Why not?".

Print ! with new line:

$ ./bf.raku -e '+++++[>++++++<-]>+++.<----[>-----<+]>---.'
!

Calc 2 * 3:

$ ./bf.raku -l 5 -D -e '++[>+++<-]>'
  [0]   0 | 00 |   | { <00> 00 00 00 00 }
+ [0]   1 | 01 |   | { <01> 00 00 00 00 }
+ [0]   2 | 02 |   | { <02> 00 00 00 00 }
> [1]   0 | 00 |   | { 02 <00> 00 00 00 }
+ [1]   1 | 01 |   | { 02 <01> 00 00 00 }
+ [1]   2 | 02 |   | { 02 <02> 00 00 00 }
+ [1]   3 | 03 |   | { 02 <03> 00 00 00 }
< [0]   2 | 02 |   | { <02> 03 00 00 00 }
- [0]   1 | 01 |   | { <01> 03 00 00 00 }
> [1]   3 | 03 |   | { 01 <03> 00 00 00 }
+ [1]   4 | 04 |   | { 01 <04> 00 00 00 }
+ [1]   5 | 05 |   | { 01 <05> 00 00 00 }
+ [1]   6 | 06 |   | { 01 <06> 00 00 00 }
< [0]   1 | 01 |   | { <01> 06 00 00 00 }
- [0]   0 | 00 |   | { <00> 06 00 00 00 }
> [1]   6 | 06 |   | { 00 <06> 00 00 00 }

See source code for available options.

gen-bf-print.raku

Utility tool to generate a brainfuck code which will print the needed text.

$ echo 'Lol! What?' | ./gen-bf-print.raku 2> stderr.txt
++++++++[>+++++++++<-]>++++.
<+++++[>+++++++<-]>.
---.
<--------[>---------<+]>---.
-.
<+++++++[>+++++++<-]>++++++.
<++++[>++++<-]>+.
-------.
<++++[>++++<-]>+++.
<-------[>-------<+]>----.
<-------[>-------<+]>----.

$ cat stderr.txt
 76 => +76 = 8 * 9 + 4 | <++++++++[>+++++++++<-]>++++
111 => +35 = 5 * 7 + 0 | <+++++[>+++++++<-]>
108 => -3 = 1 * 3 + 0 | ---
 33 => -75 = 8 * 9 + 3 | <--------[>---------<+]>---
 32 => -1 = 1 * 1 + 0 | -
 87 => +55 = 7 * 7 + 6 | <+++++++[>+++++++<-]>++++++
104 => +17 = 4 * 4 + 1 | <++++[>++++<-]>+
 97 => -7 = 2 * 3 + 1 | -------
116 => +19 = 4 * 4 + 3 | <++++[>++++<-]>+++
 63 => -53 = 7 * 7 + 4 | <-------[>-------<+]>----
 10 => -53 = 7 * 7 + 4 | <-------[>-------<+]>----

And so:

$ echo 'Lol! What?' | ./gen-bf-print.raku 2> /dev/null | ./bf.raku
Lol! What?

There is no goal. Only the way!

About

Brainfuck interpretter made with Raku for fun

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Contributors

Languages