macro_rules! BQN { ($code:expr) => { ... }; ($code:expr, $x:expr) => { ... }; ($w:expr, $code:expr, $x:expr) => { ... }; }
Expand description
Convenience macro for running BQN expressions
Takes a string of BQN code and optional left and right argument
Examples
let sum = BQN!("1+1").unwrap();
assert_eq!(sum.to_f64().unwrap(), 2.0);
let bqn_is_anagram = BQN!("⌽≡⊢", "BQN").and_then(|e| e.to_f64()).unwrap();
assert_eq!(bqn_is_anagram, 0.0);
let strs = BQN!(' ', "(⊢-˜+`׬)∘=⊔⊢", "Rust ❤️ BQN")
.and_then(|e| e.to_bqnvalue_vec())
.and_then(|v| {
v.iter()
.map(BQNValue::to_string)
.collect::<Result<Vec<String>, _>>()
})
.unwrap();
assert_eq!(strs, ["Rust", "❤️", "BQN"]);
let strings = ["join", "these", "please"];
assert_eq!(BQN!("∾", strings).and_then(|e| e.to_string()).unwrap(), "jointheseplease");