Function canrun::goals::cmp::min

source ·
pub fn min<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 lesser of two values according to std::cmp::min.

Example:

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

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