1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate;
/// Returns a vector of all operands of this formula.
///
/// _n-ary_ operators return all their operands, _binary_ operators return
/// their `left` and `right` operands, `Not` returns a vector with only its
/// inner formula, and all other formulas return an empty vector.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// # use logicng::formulas::FormulaFactory;
/// # use logicng::formulas::ToFormula;
/// # use logicng::operations::functions::operands;
/// let f = FormulaFactory::new();
///
/// let a = f.variable("a");
/// let b = f.variable("b");
/// let c = f.variable("c");
///
/// let formula1 = "a & b & c".to_formula(&f);
/// let formula2 = "a => b".to_formula(&f);
/// let formula3 = f.not(formula2);
///
/// assert_eq!(operands(a, &f), vec![]);
/// assert_eq!(operands(formula1, &f), vec![a, b, c]);
/// assert_eq!(operands(formula2, &f), vec![a, b]);
/// assert_eq!(operands(formula3, &f), vec![formula2]);
/// ```