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

  • swipl
    • library
      • error.pl
      • debug.pl
      • apply.pl -- Apply predicates on a list
      • lists.pl
      • broadcast.pl
      • shlib.pl -- Utility library for loading foreign objects (DLLs, shared objects)
      • option.pl -- Option list processing
      • thread_pool.pl -- Resource bounded thread management
      • gensym.pl
      • settings.pl
      • arithmetic.pl -- Extensible arithmetic
      • main.pl -- Provide entry point for scripts
      • readutil.pl
      • operators.pl
      • pairs.pl
      • prolog_source.pl
      • record.pl
      • quasi_quotations.pl
      • pure_input.pl
      • solution_sequences.pl
      • ordsets.pl
      • random.pl
      • base64.pl -- Base64 encoding and decoding
      • aggregate.pl -- Aggregation operators on backtrackable predicates
        • safe_meta/2
        • aggregate/3
        • aggregate/4
        • aggregate_all/3
        • aggregate_all/4
        • foldall/4
        • foreach/2
        • free_variables/4
      • yall.pl
      • sandbox.pl -- Sandboxed Prolog code
      • apply_macros.pl -- Goal expansion rules to avoid meta-calling
      • assoc.pl
      • prolog_format.pl
      • predicate_options.pl
      • csv.pl
      • pprint.pl -- Pretty Print Prolog terms
      • atom.pl
      • modules.pl
      • occurs.pl -- Finding and counting sub-terms
      • prolog_xref.pl
      • prolog_colour.pl
      • lazy_lists.pl -- Lazy list handling
      • ugraphs.pl -- Graph manipulation library
      • url.pl
      • www_browser.pl
      • prolog_pack.pl
      • git.pl
      • utf8.pl
      • dialect.pl
      • system.pl -- System utilities
      • terms.pl
      • date.pl
      • persistency.pl
      • iostream.pl -- Utilities to deal with streams
      • prolog_stack.pl
      • edinburgh.pl
      • prolog_clause.pl
      • prolog_breakpoints.pl -- Manage Prolog break-points
      • wfs.pl
      • prolog_code.pl
      • sort.pl
      • dicts.pl -- Dict utilities
      • dif.pl -- The dif/2 constraint
      • varnumbers.pl -- Utilities for numbered terms
      • pio.pl
      • quintus.pl
      • threadutil.pl -- Interactive thread utilities
      • rbtrees.pl
      • backcomp.pl -- Backward compatibility
      • base32.pl -- Base32 encoding and decoding
      • charsio.pl
      • codesio.pl
      • coinduction.pl
      • heaps.pl
      • statistics.pl
      • when.pl
      • prolog_profile.pl
      • make.pl -- Reload modified source files
      • qsave.pl
      • zip.pl
      • streams.pl -- Manage Prolog streams
      • ansi_term.pl -- Print decorated text to ANSI consoles
      • prolog_history.pl
      • prolog_config.pl
      • shell.pl -- Elementary shell commands
      • check.pl -- Consistency checking
      • optparse.pl -- command line parsing
      • prolog_debug.pl -- User level debugging tools
      • macros.pl
      • thread.pl -- High level thread primitives
      • prolog_autoload.pl
      • strings.pl
      • nb_set.pl -- Non-backtrackable sets
      • ctypes.pl -- Character code classification
      • prolog_jiti.pl
      • listing.pl
      • prolog_metainference.pl
      • prolog_codewalk.pl
      • prolog_versions.pl
      • portray_text.pl
      • tty.pl
      • prolog_coverage.pl -- Coverage analysis tool
      • rwlocks.pl
      • prolog_wrap.pl
      • fastrw.pl
      • intercept.pl
      • increval.pl
      • tables.pl
      • hashtable.pl
      • explain.pl
      • writef.pl
      • exceptions.pl
      • files.pl
      • readln.pl
      • edit.pl
      • prolog_trace.pl
      • help.pl
      • oset.pl
 foldall(:Folder, :Goal, +V0, -V) is det
Use Folder to fold V0 to V using all answers of Goal. This predicate generates all answers for Goal and for each answer it calls call(Folder,V0,V1). This predicate provides behaviour similar to aggregate_all/3-4, but operates in constant space and allows for custom aggregation (Folder) operators. The example below uses plus/3 to realise aggregate_all(sum(X), between(1,10,X), Sum).
?- foldall(plus(X), between(1,10,X), 0, Sum).
Sum = 55

The implementation uses nb_setarg/3 for non-backtrackable state updates.

See also
- aggregate_all/3-4, foldl/4-7, nb_setarg/3.