/usr/local/lib/swipl/library/occurs.pl
All Application Manual Name SummaryHelp

  • swipl
    • library
      • error.pl
      • debug.pl -- Print debug messages and test assertions
      • apply.pl -- Apply predicates on a list
      • lists.pl
      • broadcast.pl -- Event service
      • shlib.pl -- Utility library for loading foreign objects (DLLs, shared objects)
      • option.pl
      • thread_pool.pl
      • gensym.pl
      • settings.pl
      • arithmetic.pl
      • main.pl
      • readutil.pl
      • operators.pl -- Manage operators
      • pairs.pl -- Operations on key-value lists
      • prolog_source.pl -- Examine Prolog source-files
      • record.pl
      • quasi_quotations.pl
      • pure_input.pl
      • solution_sequences.pl
      • ordsets.pl
      • random.pl -- Random numbers
      • base64.pl
      • aggregate.pl
      • yall.pl
      • sandbox.pl
      • apply_macros.pl -- Goal expansion rules to avoid meta-calling
      • assoc.pl
      • prolog_format.pl -- Analyse format specifications
      • predicate_options.pl
      • csv.pl -- Process CSV (Comma-Separated Values) data
      • pprint.pl
      • atom.pl
      • modules.pl
      • occurs.pl -- 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
      • prolog_xref.pl
      • prolog_colour.pl
      • lazy_lists.pl
      • ugraphs.pl -- Graph manipulation library
      • url.pl
      • www_browser.pl -- Open a URL in the users browser
      • prolog_pack.pl
      • git.pl
      • rbtrees.pl -- Red black trees
      • dif.pl
      • charsio.pl
      • prolog_stack.pl -- Examine the Prolog stack
      • edinburgh.pl -- Some traditional Edinburgh predicates
      • prolog_clause.pl
      • prolog_breakpoints.pl -- Manage Prolog break-points
      • wfs.pl
      • dialect.pl
      • prolog_code.pl -- Utilities for reasoning about code
      • sort.pl
      • iostream.pl -- Utilities to deal with streams
      • dicts.pl
      • varnumbers.pl
      • base32.pl
      • codesio.pl
      • coinduction.pl -- Co-Logic Programming
      • date.pl -- Process dates and times
      • heaps.pl
      • statistics.pl
      • terms.pl -- Term manipulation
      • utf8.pl -- UTF-8 encoding/decoding on lists of character codes.
      • when.pl
      • backcomp.pl
      • threadutil.pl -- Interactive thread utilities
      • check.pl -- Consistency checking
      • oset.pl
      • prolog_codewalk.pl -- Prolog code walker
      • tables.pl
      • quintus.pl
      • shell.pl
      • prolog_jiti.pl -- Just In Time Indexing (JITI) utilities
      • rwlocks.pl
      • portray_text.pl -- Portray text
      • prolog_profile.pl -- Execution profiler
      • zip.pl
      • listing.pl -- List programs and pretty print clauses
      • prolog_metainference.pl -- Infer meta-predicate properties
      • optparse.pl
      • prolog_debug.pl -- User level debugging tools
      • ansi_term.pl -- Print decorated text to ANSI consoles
      • writef.pl
      • persistency.pl
      • increval.pl -- Incremental dynamic predicate modification
      • thread.pl -- High level thread primitives
      • strings.pl -- String utilities
      • edit.pl -- Editor interface
      • prolog_coverage.pl
      • prolog_versions.pl
      • prolog_autoload.pl
      • make.pl -- Reload modified source files
      • ctypes.pl -- Character code classification
      • nb_set.pl -- Non-backtrackable sets
      • explain.pl
      • qsave.pl
      • fastrw.pl
 occurrences_of_term(@SubTerm, @Term, ?Count) is det
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.