fix nth_instance: fix bugs and actually add two versions (obs from Theofrastos Mantadelis)

This commit is contained in:
Vítor Manuel de Morais Santos Costa
2009-11-18 13:06:37 +00:00
parent f31aeff952
commit a316090f8c
4 changed files with 40 additions and 21 deletions

View File

@@ -472,12 +472,20 @@ callable(V) :- var(V), !, fail.
callable(V) :- atom(V), !.
callable(V) :- functor(V,_,Ar), Ar > 0.
nth_instance(X,Y,Z) :-
nonvar(X), var(Y), var(Z), !,
recorded(X,_,Z),
'$nth_instance'(_,Y,Z).
nth_instance(X,Y,Z) :-
'$nth_instance'(X,Y,Z).
nth_instance(Key,Index,Ref) :-
nonvar(Key), var(Index), var(Ref), !,
recorded(Key,_,Ref),
'$nth_instance'(_,Index,Ref).
nth_instance(Key,Index,Ref) :-
'$nth_instance'(Key,Index,Ref).
nth_instance(Key,Index,T,Ref) :-
nonvar(Key), var(Index), var(Ref), !,
recorded(Key,T,Ref),
'$nth_instance'(_,Index,Ref).
nth_instance(Key,Index,T,Ref) :-
'$nth_instance'(Key,Index,Ref),
instance(Ref,T).
nb_current(GlobalVariable, Val) :-
var(GlobalVariable), !,