]>
Witch of Git - mukan/blob - src/bin/readme_examples.rs
1 use mukan
::{all
, and
, call_fresh
, delay
, eq
, fresh
, or
, reify_vars
, Goal
, State
, Term
};
4 let goal
= call_fresh(|x
| eq(413, x
));
5 for soln
in goal
.search(State
::new()) {
9 let goal
= call_fresh(|x
| or(eq(612, x
), eq(1025, x
)));
10 for soln
in goal
.search(State
::new()) {
14 let goal
= fresh
!((a
, b
, c
) => all
! {
18 for soln
in goal
.search(State
::new()) {
22 let (vars
, state
) = State
::with_vars(2);
23 let (a
, b
) = (vars
[0], vars
[1]);
24 let goal
= fresh
!((c
) => all
! {
28 for soln
in goal
.search(state
) {
29 println
!("{:?}", reify_vars(&vars
, soln
));
32 fn peano(n
: impl Into
<Term
>) -> impl Goal
{
37 eq(n
.clone(), (1, x
)),
38 delay(move || peano(x
)),
43 let (vars
, state
) = State
::with_vars(1);
44 let goal
= peano(vars
[0]);
45 for soln
in goal
.search(state
).take(10) {
46 println
!("{:?}", reify_vars(&vars
, soln
));