Function canrun::collections::lvec::slice [−][src]
pub fn slice<'a, I, SV, RV, CV, D>(
slice: SV,
range: RV,
collection: CV
) -> Goal<'a, D> where
I: UnifyIn<'a, D> + 'a,
LVec<I>: UnifyIn<'a, D>,
SV: IntoVal<LVec<I>>,
RV: IntoVal<Range<usize>>,
CV: IntoVal<LVec<I>>,
D: DomainType<'a, Range<usize>> + DomainType<'a, I> + DomainType<'a, LVec<I>>,
Expand description
Create a Goal
that attempts to unify an LVec<T>
with
a slice from another LVec<T>
defined by a [‘Range’].
Examples:
use canrun::{Goal, val, var, all, unify, lvec, example::Collections}; let needle = var(); let haystack = var(); let range = var(); let goal: Goal<Collections> = all![ unify(range, 0..2), unify(haystack, lvec![1, 2, 3]), lvec::slice(needle, range, haystack), ]; let results: Vec<_> = goal.query(needle).collect(); assert_eq!(results, vec![vec![1, 2]]);