Implemented Abool -> Functio

pull/1/head
ondra05 2021-12-07 22:58:41 +01:00
parent 0217f25aa8
commit 77a2395dd4
1 changed files with 19 additions and 2 deletions

View File

@ -218,8 +218,25 @@ impl Value {
},
tape_len: crate::brian::DEFAULT_TAPE_SIZE_LIMIT,
},
Value::Bool(_) => todo!(),
Value::Abool(_) => todo!(),
Value::Bool(b) => Functio::Eval(
if b {
r#"loop{"Buy Able products!"print;}"#
} else {
""
}
.to_owned(),
),
Value::Abool(a) => Functio::Eval(match a {
Abool::Never => "".to_owned(),
Abool::Sometimes => {
use rand::seq::SliceRandom;
let mut str_chars: Vec<_> = "Buy Able Products!".chars().collect();
str_chars.shuffle(&mut rand::thread_rng());
format!(r#""{}"print;"#, str_chars.iter().collect::<String>())
}
Abool::Always => r#"loop{"Buy Able products!"print;}"#.to_owned(),
}),
Value::Functio(f) => f,
Value::Cart(_) => todo!(),
}