Content deleted Content added
m →Lisp: Italicize `package' and replace `called' with `or'. |
No edit summary |
||
Line 15:
|-
| [[Scheme (programming language)|R6RS Scheme]] || symbol || <tt>sym</tt>
|-
| [[Prolog (programming language)|Prolog]] || atom, symbol || <tt>sym</tt>
|-
| [[Ruby (programming language)|Ruby]] || Symbol || <tt>:sym</tt> or <tt>:'sym'</tt>
Line 64 ⟶ 66:
<source lang="lisp">
package:exported-symbol
</source>
===Prolog===
In [[Prolog (programming language)|Prolog]], symbols (or atoms) are the primary primitive data types, similar to numbers.<ref name=Bratko2001>{{Cite book | last1 = Bratko | first1 = Ivan | title = Prolog programming for artificial intelligence | year = 2001 | publisher = Addison Wesley | ___location = Harlow, England ; New York | isbn = 0-201-40375-7 | pages = }}</ref> The exact notation may differ in different [[Prolog (programming language)|Prolog]]'s dialects. However, it is always quite simple (no quotations or special beginning characters are necessary).
Contrary to other languages, it is possible to give symbols some <i>meaning</i> by creating some [[Prolog (computer language)|Prolog]]'s facts and/or rules.
====Examples====
The following example demonstrates two facts (describing what <i>father</i> is) and one rule (describing the <i>meaining</i> of <i>sibling</i>). These three sentences use symbols (father, zeus, hermes, perseus and sibling) and some abstract variables (X, Y and Z). The <i>mother</i> relationship has been omitted for clarity.
<source lang="prolog">
father (zeus, hermes).
father (zeus, perseus).
sibling (X, Y) :- father (Z, X), father (Z, Y).
</source>
|