You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SWI-Prolog has call_nth/2, originally in library solution_sequences,
but meanwhile also adopted by a few other Prolog systems
in various locations, for the SWI-Prolog definition see here:
call_nth(:Goal, ?Nth)
True when Goal succeeded for the Nth time. If Nth is bound on entry,
the predicate succeeds deterministically if there are at least Nth solutions for Goal. https://www.swi-prolog.org/pldoc/doc_for?object=call_nth/2
I didn't find a predicate by the same name. I need it to run this code:
{"quote":"Winning isn’t everything, but wanting to win is.","author":"Vince Lombardi"}.
{"quote":"I am not a product of my circumstances. I am a product of my decisions.","author":"Stephen Covey"}.
{"quote":"You miss 100% of the shots you don’t take.","author":"Wayne Gretzky"}.
{"quote":"Every strike brings me closer to the next home run.","author":"Babe Ruth"}.
{"quote":"Whether you think you can or you think you can’t, you’re right.","author":"Henry Ford"}.
member_comma(Z, (X,_)) :- member_comma(Z, X).
member_comma(Z, (_,Y)) :- !, member_comma(Z, Y).
member_comma(X, X).
:- op(100,yfx,'.').
:- op(800,xfx,':=').
X := A.B :- member_comma(B:X, A).
main :- statistics(wall, W), N is W mod 5+1, call_nth({ X }, N), Q := X."quote", A := X."author",
write(Q-A), nl.
The text was updated successfully, but these errors were encountered:
Regarding ., yes, we can define as an infix operator. We needed it for some language extensions (I'm aware that some of them were introduced first in Ciao and then appeared in other systems, but it could be just convergent evolution).
jfmc
changed the title
(playground) is there a Ciao Prolog equivalent of call_nth/2 ?
call_nth/2 (was: (playground) is there a Ciao Prolog equivalent of call_nth/2 ?)
Aug 24, 2022
SWI-Prolog has call_nth/2, originally in library solution_sequences,
but meanwhile also adopted by a few other Prolog systems
in various locations, for the SWI-Prolog definition see here:
I didn't find a predicate by the same name. I need it to run this code:
The text was updated successfully, but these errors were encountered: