This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn reduce_or(stack: &mut Vec<Token>) -> Result<Token, RuntimeError> { | |
// would return Err if the vector were not entirely | |
// made of Token::Operand(Type::Bool), since we can't reduce with `or` | |
// other values | |
let bool_result = unwrap_boolean_tokens(stack); | |
if let Ok(bool_vec) = bool_result { | |
Ok(Token::Operand(Type::Bool( | |
bool_vec.iter().any(|b| *b) // and reducer has "all" here | |
))) | |
} else { | |
Err(RuntimeError{ }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment