==Examples==
===Lisp===
[[Lisp (programming language)|Lisp]] (1958) stands for "List Processor."<ref name="ArtOfLisp">{{cite book
| last1=Jones
| first1=Robin
| last2=Maynard
| first2=Clive
| last3=Stewart
| first3=Ian
| title=The Art of Lisp Programming
| date=December 6, 2012
| publisher=Springer Science & Business Media
| isbn=9781447117193
| page=2}}</ref> It is tailored to process [[List (abstract data type)|lists]]. A data structure is formed by building lists of lists. In memory, this forms a [[Tree (data structure)|tree data structure]]. Internally, the tree structure of typical Lisp data lends itself nicely to processing with [[Recursion (computer science)|recursive]] functions.<ref name="cpl_3rd-ch9-220">{{cite book
| last = Wilson
| first = Leslie B.
| title = Comparative Programming Languages, Third Edition
| publisher = Addison-Wesley
| year = 2001
| page = 220
| isbn = 0-201-71012-9
}}</ref> The syntax to build a tree is to enclose the whitespace-separated [[Element (mathematics)|elements]] within parenthesis. The following is a list of three elements. The first two elements are themselves lists of two elements each:
{{sxhl|2=lisp|((A B) (HELLO WORLD) 94)}}
Lisp has functions to extract and reconstruct elements.<ref name="cpl_3rd-ch9-221">{{cite book
| last = Wilson
| first = Leslie B.
| title = Comparative Programming Languages, Third Edition
| publisher = Addison-Wesley
| year = 2001
| page = 221
| isbn = 0-201-71012-9
}}</ref> The function <code>car</code> (sometimes called <code>first</code>) returns the first element in the list. The function <code>cdr</code> (sometimes called <code>rest</code>) returns a list containing everything but the first element. The function <code>cons</code> returns a list that is the second argument with the first prepended to it. Therefore, if X is a non-empty list, the following expression evaluates to the list <code>X</code>:
{{sxhl|2=lisp|(cons (car x) (cdr x))}}
The code itself returns a ''copy'' of the list <code>X</code>. As is typical in functional languages, operations in Lisp often copy data when asked to produce new data from old. The tree structure of Lisp data facilitates this as well: a new structure made from pre-existing data shares as much of its internal structure with its antecedents as possible, with new additions stored as branches of the tree, and references to the original structure under its original name will return exactly that and no more.
One drawback of Lisp is when many functions are nested, the parentheses may look confusing.<ref name="cpl_3rd-ch9-230">{{cite book
| last = Wilson
| first = Leslie B.
| title = Comparative Programming Languages, Third Edition
| publisher = Addison-Wesley
| year = 2001
| page = 230
| isbn = 0-201-71012-9
}}</ref> Modern Lisp [[Integrated development environment|environments]] help ensure parenthesis match. As an aside, Lisp does support the ''imperative language'' operations of the assignment statement and goto loops.<ref name="cpl_3rd-ch9-229">{{cite book
| last = Wilson
| first = Leslie B.
| title = Comparative Programming Languages, Third Edition
| publisher = Addison-Wesley
| year = 2001
| page = 229
| isbn = 0-201-71012-9
}}</ref> Also, ''Lisp'' is not concerned with the [[data type|datatype]] of the elements at compile time. Instead, it assigns the datatypes at runtime. This may lead to programming errors not being detected early in the development process. To counteract this, Lisp development is typically carried out in an extremely incremental manner, with functions and higher-order functions built up and tested live during development. Additionally, through the use of [[Macro (computer science)#Syntactic macros|macro]]s, which are Lisp functions that operate upon Lisp programs as data structures, type checking may be performed discretionally at any point the programmer wishes.
Writing large, reliable, and readable Lisp programs requires forethought. If properly planned, the program may be much shorter than an equivalent ''imperative language'' program.<ref name="cpl_3rd-ch9-230"/> ''Lisp'' is widely used in [[artificial intelligence]]. However, its usage has been accepted only because it has ''imperative language'' operations, making unintended side-effects possible.<ref name="cpl_3rd-ch9-241">{{cite book
| last = Wilson
| first = Leslie B.
| title = Comparative Programming Languages, Third Edition
| publisher = Addison-Wesley
| year = 2001
| page = 241
| isbn = 0-201-71012-9
}}</ref>
===ML===
[[ML (programming language)|ML]] (1973)<ref name="Gordon1996">{{cite web
| last = Gordon
| first = Michael J. C.
| author-link = Michael J. C. Gordon
| year=1996
| title = From LCF to HOL: a short history
| url = http://www.cl.cam.ac.uk/~mjcg/papers/HolHistory.html
| access-date = 2021-10-30}}</ref> stands for "Meta Language." ML is statically typed, and function arguments and return types may be annotated.<ref name="cpl_3rd-ch9-233">{{cite book
| last = Wilson
| first = Leslie B.
| title = Comparative Programming Languages, Third Edition
| publisher = Addison-Wesley
| year = 2001
| page = 233
| isbn = 0-201-71012-9
}}</ref>
{{sxhl|2=sml|1=fun times_10(n : int) : int = 10 * n;}}
''ML'' is not as bracket-centric as ''Lisp'', and instead uses a wider variety of syntax to codify the relationship between code elements, rather than appealing to list ordering and nesting to express everything. The following is an application of <code>times_10</code>:
times_10 2
It returns "20 : int", that is, <code>20</code>, a value of type <code>int</code>.
Like ''Lisp'', ''ML'' is tailored to process lists, though all elements of a list must be the same type.<ref name="cpl_3rd-ch9-235">{{cite book
| last = Wilson
| first = Leslie B.
| title = Comparative Programming Languages, Third Edition
| publisher = Addison-Wesley
| year = 2001
| page = 235
| isbn = 0-201-71012-9
}}</ref>
===Prolog===
Most implementations of ASP execute a program by first "grounding" the program, replacing all variables in rules by constants in all possible ways, and then using a propositional SAT solver, such as the [[DPLL algorithm]] to generate one or more models of the program.
Its applications are oriented towards solving difficult [[search algorithm|search problems]] and [[knowledge representation]].<ref>{{cite book |first=Chitta |last=Baral |title=Knowledge Representation, Reasoning and Declarative Problem Solving |url=https://archive.org/details/knowledgereprese00bara |url-access=registration |year=2003 |publisher=Cambridge University Press |isbn=978-0-521-81802-5}}</ref><ref>{{cite book |first=Michael |last=Gelfond |chapter=Answer sets |editor1-first=Frank |editor1-last=van Harmelen |editor2-first=Vladimir |editor2-last=Lifschitz |editor3-first=Bruce |editor3-last=Porter |title=Handbook of Knowledge Representation |chapter-url=https://books.google.com/books?id=xwBDylHhJhYC&pg=PA285 |year=2008 |publisher=Elsevier |isbn=978-0-08-055702-1 |pages=285–316 }} [http://www.depts.ttu.edu/cs/research/krlab/pdfs/papers/gel07b.pdf as PDF] {{Webarchive|url=https://web.archive.org/web/20160303231241/http://www.depts.ttu.edu/cs/research/krlab/pdfs/papers/gel07b.pdf |date=2016-03-03 }}</ref>
==See also==
|