ADDED: succ/2, part of the Prologue for Prolog
Specification: https://www.complang.tuwien.ac.at/ulrich/iso-prolog/prologue#succ
This commit is contained in:
@@ -14,6 +14,7 @@ but they're not part of the ISO Prolog standard at the moment.
|
|||||||
partial_string/3,
|
partial_string/3,
|
||||||
partial_string_tail/2,
|
partial_string_tail/2,
|
||||||
setup_call_cleanup/3,
|
setup_call_cleanup/3,
|
||||||
|
succ/2,
|
||||||
call_nth/2,
|
call_nth/2,
|
||||||
countall/2,
|
countall/2,
|
||||||
copy_term_nat/2,
|
copy_term_nat/2,
|
||||||
@@ -112,6 +113,23 @@ bb_get(Key, Value) :-
|
|||||||
).
|
).
|
||||||
|
|
||||||
|
|
||||||
|
%% succ(?I, ?S).
|
||||||
|
%
|
||||||
|
% True iff S is the successor of the non-negative integer I.
|
||||||
|
% At least one of the arguments must be instantiated.
|
||||||
|
|
||||||
|
succ(I, S) :-
|
||||||
|
can_be(not_less_than_zero, I),
|
||||||
|
can_be(not_less_than_zero, S),
|
||||||
|
( integer(I) ->
|
||||||
|
S is I+1
|
||||||
|
; integer(S) ->
|
||||||
|
S > 0,
|
||||||
|
I is S-1
|
||||||
|
; instantiation_error(succ/2)
|
||||||
|
).
|
||||||
|
|
||||||
|
|
||||||
% setup_call_cleanup.
|
% setup_call_cleanup.
|
||||||
|
|
||||||
:- meta_predicate(call_cleanup(0, 0)).
|
:- meta_predicate(call_cleanup(0, 0)).
|
||||||
|
|||||||
Reference in New Issue
Block a user