- swipl
- library
- error.pl
- debug.pl -- Print debug messages and test assertions
- apply.pl
- lists.pl
- broadcast.pl
- shlib.pl
- option.pl
- thread_pool.pl
- gensym.pl
- settings.pl
- arithmetic.pl -- Extensible arithmetic
- main.pl -- Provide entry point for scripts
- readutil.pl
- operators.pl
- pairs.pl
- prolog_source.pl
- quasi_quotations.pl
- url.pl
- www_browser.pl
- prolog_colour.pl
- record.pl
- prolog_xref.pl
- occurs.pl
- ordsets.pl
- assoc.pl
- ugraphs.pl
- solution_sequences.pl
- atom.pl
- prolog_pack.pl
- git.pl
- ctypes.pl
- utf8.pl
- base64.pl
- persistency.pl
- pure_input.pl -- Pure Input from files and streams
- nb_set.pl
- aggregate.pl -- Aggregation operators on backtrackable predicates
- csv.pl -- Process CSV (Comma-Separated Values) data
- iostream.pl -- Utilities to deal with streams
- dialect.pl -- Support multiple Prolog dialects
- apply_macros.pl -- Goal expansion rules to avoid meta-calling
- yall.pl
- prolog_code.pl -- Utilities for reasoning about code
- dif.pl -- The dif/2 constraint
- thread.pl -- High level thread primitives
- predicate_options.pl
- rbtrees.pl
- nb_rbtrees.pl
- sandbox.pl
- prolog_format.pl
- random.pl
- pprint.pl
- modules.pl -- Module utility predicates
- lazy_lists.pl
- edinburgh.pl
- prolog_clause.pl
- prolog_breakpoints.pl
- dicts.pl
- tables.pl
- threadutil.pl -- Interactive thread utilities
- base32.pl
- date.pl
- backcomp.pl
- prolog_trace.pl
- intercept.pl
- prolog_stack.pl
- oset.pl -- Ordered set manipulation
- prolog_profile.pl
- listing.pl
- quintus.pl
- prolog_coverage.pl
- zip.pl
- check.pl
- ansi_term.pl
- prolog_wrap.pl
- make.pl
- optparse.pl
- prolog_debug.pl -- User level debugging tools
- shell.pl
- prolog_codewalk.pl
- charsio.pl
- prolog_history.pl
- prolog_config.pl
- explain.pl
- files.pl
- wfs.pl
- library
- arithmetic_function(:NameArity) is det
- Declare a predicate as an arithmetic function. The function is
visible in the module in which it is defined as well as modules that
import the implementation predicate or inherit from this module. For
example:
:- use_module(library(arithmetic)). :- arithmetic_function(mid/2). mid(A,B,C) :- C is (A+B)/2.
After which we may call
?- A is mid(3,5)., resulting inA = 4.The implementation uses goal_expansion/2 to rewrite an arithmetic expression using user functions into a conjunction of arithmetic evaluation and predicate calls. This implies that the expression must be known at compile time. Runtime evaluation is supported using arithmetic_expression_value/2.
- deprecated
- - This function provides a partial work around for pure Prolog user-defined arithmetic functions that has been dropped in SWI-Prolog 5.11.23. Notably, it only deals with expression know at compile time.