Help with from_to/2
#3038
-
Hi, What do I have wrong here in my code? :- use_module(clpz).
from_to(From, To) :-
From #=< To,
NextFrom #= From + 1,
from_to(NextFrom, To).
?- from_to(From, 5), label(From). https://git.sr.ht/~whereiseveryone/prolog-scratch/tree/master/loop.pl#L6 |
Beta Was this translation helpful? Give feedback.
Answered by
jgarte
Aug 9, 2025
Replies: 2 comments
-
fixed 😊 :- use_module(clpz).
from_to(To, To).
from_to(From, To) :-
From #< To,
From #> 0,
NextFrom #= From + 1,
from_to(NextFrom, To).
?- from_to(From, 5).
%@ From = 5
%@ ; From = 4
%@ ; From = 3
%@ ; From = 2
%@ ; From = 1
%@ ; false. https://git.sr.ht/~whereiseveryone/prolog-scratch/tree/master/loop.pl#L12 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jgarte
-
Note the following irregularities:
Rather
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fixed 😊
https://git.sr.ht/~whereiseveryone/prolog-scratch/tree/master/loop.pl#L12