|
As we near the second round of the ACSL competition, we have all spent a long time learning and practicing the various topics that will be tested. One of these topics is the LISP programming language. Before I began studying for the contest, I had no idea that there existed such a lanuage, and for good reason, as it is no longer prominent today. LISP was invented in the 1950s to develop artificial intelligence, and its use nowadays is dwarfed by those of modern programming languages like Python and Java. Considering this, I didn't understand why ACSL still tested this topic. However, as I learned more about the specifics of LISP, I realized that it is based on a different system of logic than modern languages.
LISP's syntax is centered around the list data structure. This means that every line in LISP, including every variable, every function, and every conditional, is part of a list. An entire program written in LISP is actually one giant list with smaller sublists nested within the greater framework. This principle makes recursion inherent to the language. Recursion is the process of calling a function within that same function to divide a problem into smaller problems, a simple and elegant process. It is often more convenient to use a recursive algorithm than an iterative one in LISP, as it conforms with its fundamental structure. This prompts many programmers studying the language to think recursively, a new perspective that can often simplify the solution to a problem.
Another effect of LISP's list-based structure is its compatibility with many widely used data structures in computer science, namely linked lists, trees, and graphs. All lists in LISP take the form of a linked list, with the function CAR returning the first element of a list and CDR returning the rest of the list excluding the first element. This works essentially like a linked list, with the two functions forming the pairs, or con cells, that compose such lists. Each call of the two functions advances through the list, covering it entirely with its series of references to the next element from the previous one. This recursive logic also applies to graphs and trees as well, making LISP a formidable tool to explore the fundamental ideas of computer science. |
|