/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 -- Resource bounded thread management
      • gensym.pl -- Generate unique symbols
      • settings.pl -- Setting management
      • arithmetic.pl -- Extensible arithmetic
      • main.pl -- Provide entry point for scripts
      • readutil.pl -- Read utilities
      • operators.pl
      • pairs.pl -- Operations on key-value lists
      • prolog_source.pl -- Examine Prolog source-files
      • record.pl -- Access compound arguments by name
      • quasi_quotations.pl -- Define Quasi Quotation syntax
      • pure_input.pl
      • solution_sequences.pl
      • ordsets.pl
      • random.pl
      • base64.pl
      • aggregate.pl -- Aggregation operators on backtrackable predicates
      • yall.pl -- Lambda expressions
      • sandbox.pl -- Sandboxed Prolog code
      • apply_macros.pl -- Goal expansion rules to avoid meta-calling
      • assoc.pl -- Binary associations
      • prolog_format.pl
      • predicate_options.pl
      • csv.pl -- Process CSV (Comma-Separated Values) data
      • pprint.pl
      • atom.pl -- Operations on atoms
      • 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 cross-referencer data collection
      • prolog_colour.pl
      • lazy_lists.pl -- Lazy list handling
      • ugraphs.pl
      • url.pl -- Analysing and constructing URL
      • www_browser.pl -- Open a URL in the users browser
      • prolog_pack.pl
      • git.pl
      • rbtrees.pl -- Red black trees
      • dif.pl -- The dif/2 constraint
      • 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 -- Well Founded Semantics interface
      • dialect.pl -- Support multiple Prolog dialects
      • prolog_code.pl
      • sort.pl
      • iostream.pl -- Utilities to deal with streams
      • dicts.pl -- Dict utilities
      • varnumbers.pl -- Utilities for numbered terms
      • prolog_jiti.pl
      • intercept.pl -- Intercept and signal interface
      • increval.pl
      • tables.pl -- XSB interface to tables
      • help.pl
      • thread.pl
      • shell.pl
      • backcomp.pl -- Backward compatibility
      • ansi_term.pl -- Print decorated text to ANSI consoles
      • prolog_versions.pl -- Demand specific (Prolog) versions
      • base32.pl -- Base32 encoding and decoding
      • codesio.pl
      • coinduction.pl -- Co-Logic Programming
      • date.pl -- Process dates and times
      • heaps.pl -- heaps/priority queues
      • statistics.pl -- Get information about resource usage
      • terms.pl
      • utf8.pl
      • when.pl -- Conditional coroutining
      • quintus.pl -- Quintus compatibility
      • check.pl
      • make.pl -- Reload modified source files
      • prolog_codewalk.pl -- Prolog code walker
      • listing.pl -- List programs and pretty print clauses
      • edit.pl -- Editor interface
      • prolog_history.pl
      • prolog_profile.pl -- Execution profiler
      • threadutil.pl -- Interactive thread utilities
      • prolog_metainference.pl
      • ctypes.pl -- Character code classification
      • prolog_debug.pl
      • prolog_trace.pl -- Print access to predicates
      • portray_text.pl -- Portray text
      • prolog_coverage.pl -- Coverage analysis tool
      • prolog_autoload.pl -- Autoload all dependencies
      • persistency.pl
      • zip.pl
      • macros.pl -- Macro expansion
      • explain.pl
      • optparse.pl
      • qsave.pl
      • system.pl -- System utilities
      • streams.pl -- Manage Prolog streams
      • rwlocks.pl
      • writef.pl
      • nb_set.pl
      • fastrw.pl -- Fast reading and writing of terms
      • prolog_wrap.pl -- Wrapping predicates
      • strings.pl -- String utilities
      • hashtable.pl -- Hash tables
      • oset.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.