3 unstable releases
0.2.0 | Apr 11, 2022 |
---|---|
0.1.1 | Sep 8, 2020 |
0.1.0 | Aug 24, 2020 |
#1261 in Rust patterns
15KB
344 lines
Brain Flak Macro
Write Brain-Flak code inside rust. You can pass a vector for input. The brain_flak
macro will expand to stack manipulation.
use brain_flak_macro::brain_flak;
let mut vec: Vec<i32> = vec![20, 5];
brain_flak! { &mut vec =>
// multiplication
([({}<([({}(<()>))<>](<()>))<>>)<>]){({}[()]<(({})<({}{})>)>)<>}{}{}<>{}{}{}<>
}
assert_eq!(vec![100], vec);
Why
I was about to make brainfuck macro but it already exist. A random guy from some random discord server suggested Brain-Flak instead. It's choice of using balanced brackets make it easy enough for just using macro_rules
(No).
lib.rs
:
Stack manipulation with Brain-Flak.
use brain_flak_macro::brain_flak;
let mut vec = vec![20, 5];
brain_flak! { &mut vec =>
// multiplication
([({}<([({}(<()>))<>](<()>))<>>)<>]){({}[()]<(({})<({}{})>)>)<>}{}{}<>{}{}{}<>
}
assert_eq!(vec![100], vec);