• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

4.16 Examining the program
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Examining the program
          • current_atom/1
          • current_blob/2
          • current_functor/2
          • current_flag/1
          • current_key/1
          • current_predicate/1
          • current_predicate/2
          • predicate_property/2
          • dwim_predicate/2
          • clause/2
          • clause/3
          • nth_clause/3
          • clause_property/2
    • Packages
Availability:built-in
nth_clause(?Pred, ?Index, ?Reference)
Provides access to the clauses of a predicate using their index number. Counting starts at 1. If Reference is specified it unifies Pred with the most general term with the same name/arity as the predicate and Index with the index number of the clause. Otherwise the name and arity of Pred are used to determine the predicate. If Index is provided, Reference will be unified with the clause reference. If Index is unbound, backtracking will yield both the indexes and the references of all clauses of the predicate. The following example finds the 2nd clause of append/3:
?- use_module(library(lists)).
...
?- nth_clause(append(_,_,_), 2, Ref), clause(Head, Body, Ref).
Ref = <clause>(0x994290),
Head = lists:append([_G23|_G24], _G21, [_G23|_G27]),
Body = append(_G24, _G21, _G27).
ClioPatria (version V3.1.1-51-ga0b30a5)