Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Prolog
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Data types === Prolog's single [[data type]] is the ''term''. Terms are either ''[[symbol (programming)#Prolog|atom]]s'', ''numbers'', ''variables'' or ''compound terms''.<ref group=note> The Prolog terminology differs from that of [[First-order logic|logic]]. A term of Prolog is (depending on the context) a [[Term (logic)|term]] or an [[atomic formula]] of logic. An atom in a standard logic terminology means an [[atomic formula]]; an atom of Prolog (depending on the context) is a constant, function symbol or predicate symbol of logic. </ref> * An '''atom''' is a symbol name starting with a lower case letter or guarded by quotes. Examples of atoms include <code>x</code>, <code>red</code>, <code>'Taco'</code>, <code>'some atom'</code>, and <code>'p(a)'</code>. * '''Numbers''' can be [[floating-point arithmetic|floats]] or [[integer]]s. Most of the major Prolog systems support arbitrary length integer numbers. * '''Variables''' are denoted by a string consisting of letters, numbers and underscore characters, and beginning with an upper-case letter or underscore. Variables closely resemble variables in logic in that they are placeholders for arbitrary terms. * A '''compound term''' is composed of an atom called a "functor" and a number of "arguments", which are again terms. Compound terms are ordinarily written as a functor followed by a comma-separated list of argument terms, which is contained in parentheses. The number of arguments is called the term's [[arity]]. An atom can be regarded as a compound term with [[arity]] zero. An example of a compound term is <code>person_friends(zelda,[tom,jim])</code>. Special cases of compound terms: * A ''List'' is an ordered collection of terms. It is denoted by square brackets with the terms separated by commas, or in the case of the empty list, by <code>[]</code>. For example, <code>[1,2,3,4]</code> or <code>[red,green,blue]</code>. * ''Strings'': A sequence of characters surrounded by quotes is equivalent to either a list of (numeric) character codes, a list of characters (atoms of length 1), or an atom depending on the value of the Prolog flag <code>double_quotes</code>. For example, <code>"to be, or not to be"</code>.<ref name="ISO 13211-1 6.3.7">ISO/IEC 13211-1:1995 Prolog, 6.3.7 Terms - double quoted list notation. [[International Organization for Standardization]], Geneva.</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)