Function canrun::goals::cmp::max

source ·
pub fn max<T, A, B, C>(a: A, b: B, c: C) -> impl Goalwhere
    T: Unify + PartialOrd,
    A: Into<Value<T>>,
    B: Into<Value<T>>,
    C: Into<Value<T>>,
Expand description

Get the greater of two values according to std::cmp::max.

Example:

use canrun::{unify, all, LVar, Query};
use canrun::cmp::max;

let (x, y, z) = (LVar::new(), LVar::new(), LVar::new());
let goal = all![
    unify(x, 1),
    unify(y, 2),
    unify(z, 2),
    max(x, y, z),
];
let results: Vec<_> = goal.query((x, y, z)).collect();
assert_eq!(results, vec![(1, 2, 2)]);