head 1.17; access; symbols; locks ulrich:1.17; strict; comment @# @; 1.17 date 2023.07.07.16.47.49; author ulrich; state Exp; branches; next 1.16; 1.16 date 2023.07.06.17.14.50; author ulrich; state Exp; branches; next 1.15; 1.15 date 2023.06.26.08.03.36; author ulrich; state Exp; branches; next 1.14; 1.14 date 2023.06.26.07.56.43; author ulrich; state Exp; branches; next 1.13; 1.13 date 2023.06.10.16.13.43; author ulrich; state Exp; branches; next 1.12; 1.12 date 2023.06.10.15.22.37; author ulrich; state Exp; branches; next 1.11; 1.11 date 2022.08.05.17.26.12; author ulrich; state Exp; branches; next 1.10; 1.10 date 2022.05.18.09.25.58; author ulrich; state Exp; branches; next 1.9; 1.9 date 2022.05.13.06.26.08; author ulrich; state Exp; branches; next 1.8; 1.8 date 2022.04.19.10.45.31; author ulrich; state Exp; branches; next 1.7; 1.7 date 2022.04.19.10.39.51; author ulrich; state Exp; branches; next 1.6; 1.6 date 2022.04.19.10.35.22; author ulrich; state Exp; branches; next 1.5; 1.5 date 2022.04.19.08.24.24; author ulrich; state Exp; branches; next 1.4; 1.4 date 2022.04.19.08.22.28; author ulrich; state Exp; branches; next 1.3; 1.3 date 2022.04.19.08.14.09; author ulrich; state Exp; branches; next 1.2; 1.2 date 2022.04.19.08.11.49; author ulrich; state Exp; branches; next 1.1; 1.1 date 2022.04.19.08.08.37; author ulrich; state Exp; branches; next ; desc @@ 1.17 log @Description updated @ text @
call_nth(G_0, Nth)
is true iff call(G_0)
is
true and N being the number of re-executions
of call(G_0)
, Nth
unifies with the integer N+1.
Procedurally, call_nth(G_0, Nth)
is executed as
follows:
Nth
is an integer smaller or equal N,
the goal fails,
Nth
, the goal fails,
call(G_0)
,
Nth
with counter N,
call_nth(G_0, Nth)
is re-executable. On backtracking,
continue at p.p.9.1 g.
call_nth(?term, ?integer)
G_0
is a variable and Nth
is not zeroinstantiation_error.
G_0
is neither a variable nor a callable termNth
is not zerotype_error(callable, G_0).
Nth
is neither a variable nor an integertype_error(integer, Nth).
Nth
is an integer less than zerodomain_error(not_less_than_zero, Nth).
bounded
is true
and
at stepmax_integer
evaluation_error(int_overflow).
representation_error(max_integer).
?- call_nth(true, Nth). Nth = 1. ?- call_nth(false, Nth). false. ?- call_nth(repeat, Nth). Nth = 1 ; Nth = 2 ; Nth = 3 ; Nth = 4 ; Nth = 5 ; ... . ?- call_nth(( N = 1 ; N = 2 ), Nth). N = 1, Nth = 1 ; N = 2, Nth = 2. ?- call_nth(true, non_integer). type_error(integer,non_integer). ?- call_nth(true, 1.0). type_error(integer,1.0). ?- call_nth(true, 0). false. ?- call_nth(repeat, 0). false. ?- call_nth(repeat, -1). domain_error(not_less_than_zero,-1). ?- call_nth(length(L,N), 3). L = [_A,_B], N = 2. ?- call_nth(inex, 0). false. % thus not existence_error(procedure,inex/0) ?- call_nth(inex, 0). existence_error(procedure,_), unexpected. ?- call_nth(1, 0). false. ?- call_nth(V, 0). false. ?- call_nth(N = 1, N). N = 1. ?- call_nth(N = -1, N). false. ?- call_nth(repeat,1+1). type_error(integer,1+1).
Nth
unifies with the integer being the
N+1st re-execution of call(G_0)
.
@
1.15
log
@*** empty log message ***
@
text
@d199 3
d214 1
@
1.14
log
@*** empty log message ***
@
text
@d196 3
@
1.13
log
@Cleanup from previous alternative
@
text
@d206 2
@
1.12
log
@*** empty log message ***
@
text
@d189 1
a189 1
false. % or type_error(callable,1)
d192 1
a192 1
false. % or instantiation_error
@
1.11
log
@post, example added
@
text
@d71 1
a71 1
This draft is proposed for consideration of WG17 for its inclusion into the Prolog
d77 1
a77 1
call_nth(?term, ?integer)
call_nth(+callable_term, ?integer)
max_integer
representation_error(max_integer).
d187 3
@
1.7
log
@m
@
text
@d149 1
d152 1
d160 1
d164 1
d167 1
d170 1
d173 1
d176 1
d179 1
d182 1
d185 1
d188 1
@
1.6
log
@Complete change of procedural description
@
text
@d121 1
a121 1
call_nth(+callable_term, ?integer)
or
d130 1
a130 1
and Nth
is not zero—
d140 1
a140 2
at step n.n.n.1 e N+1 is larger than max_integer
—
@
1.5
log
@These comma rules...
@
text
@d91 1
a91 1
call(G_0)
,
d96 2
a97 1
Nth
with counter N,
d103 1
a103 1
call(G_0)
,
d109 1
a109 1
call_nth(+callable_term, ?integer)
call_nth(?term, ?integer)
d139 4
@
1.4
log
@.1 was missing
@
text
@d97 1
a97 1
call(G_0)
,
@
1.1
log
@Initial revision
@
text
@d68 2
a69 2
2022-04-02
@