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

A.30 library(occurs): Finding and counting sub-terms
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • The SWI-Prolog library
        • library(occurs): Finding and counting sub-terms
          • contains_term/2
          • contains_var/2
          • free_of_term/2
          • free_of_var/2
          • occurrences_of_term/3
          • occurrences_of_var/3
          • sub_term/2
          • sub_var/2
          • sub_term_shared_variables/3
    • Packages
Availability::- use_module(library(occurs)).(can be autoloaded)
Source[det]occurrences_of_term(@SubTerm, @Term, ?Count)
Count the number of SubTerms in Term that unify with SubTerm. As this predicate is implemented using backtracking, SubTerm and Term are not further instantiated. Possible constraints are enforced. For example, we can count the integers in Term using
?- freeze(S, integer(S)), occurrences_of_term(S, f(1,2,a), C).
C = 2,
freeze(S, integer(S)).
See also
occurrences_of_var/3 for an equality (==/2) based variant.
ClioPatria (version V3.1.1-51-ga0b30a5)