3 ms·
I wish I had never opened this thread... I hate Prolog with a burning passion now, I just thought it was weird earlier. It makes brainfuck look like a walk in t
by mikewarot 4y ago
I wish I had never opened this thread... I hate Prolog with a burning passion now, I just thought it was weird earlier. It makes brainfuck look like a walk in the park.
?- write(10-2).
10-2
true.
Why do I care? I figured out how to count to 5
?- foreach(between(0,5,N),writeln(N)).
0
1
2
3
4
5
true.
Then since there's no way to count down, I figured I'd just do a bit of math
?- foreach(between(0,5,N),writeln(5-N)).
5-0
5-1
5-2
5-3
5-4
5-5
true.
I can not find a single way to force the evaluation before printing, it's nuts!
- Avshalom 4y agoarithmetic is evaluated by 'is' ?- A is 10-2, write(A). 8 A = 8. %or ?- use_module(library(clpfd)). true. ?- A #= 10-2, write(A). 8 A = 8. %this lets you do the other thing too ?- 8 #= A-2, write(A). 10 A = 10. foreach doesn't really work the way you want it though, in this case you want forall. ?- forall(between(0,5,N), (A is 5-N,writeln(A))). 5 4 3 2 1 0 true.
- mikewarot 4y agoWow... ok... I can calm down a bit... thanks for the help!
- deleted 4y ago[deleted]