Category: 07. Lisp
-
CLOS
Common LISP predated the advance of object-oriented programming by couple of decades. However, it object-orientation was incorporated into it at a later stage. Defining Classes The defclass macro allows creating user-defined classes. It establishes a class as a data type. It has the following syntax − The slots are variables that store data, or fields. A slot-description…
-
Error Handling
In Common LISP terminology, exceptions are called conditions. In fact, conditions are more general than exceptions in traditional programming languages, because a condition represents any occurrence, error, or not, which might affect various levels of function call stack. Condition handling mechanism in LISP, handles such situations in such a way that conditions are used to signal warning…
-
Packages
In general term of programming languages, a package is designed for providing a way to keep one set of names separate from another. The symbols declared in one package will not conflict with the same symbols declared in another. This way packages reduce the naming conflicts between independent code modules. The LISP reader maintains a…
-
Structures
Structures are one of the user-defined data type, which allows you to combine data items of different kinds. Structures are used to represent a record. Suppose you want to keep track of your books in a library. You might want to track the following attributes about each book − Defining a Structure The defstruct macro in LISP…
-
File I/O
We have discussed about how standard input and output is handled by common LISP. All these functions work for reading from and writing into text and binary files too. Only difference is in this case the stream we use is not standard input or output, but a stream created for the specific purpose of writing…
-
Input & Output
Common LISP provides numerous input-output functions. We have already used the format function, and print function for output. In this section, we will look into some of the most commonly used input-output functions provided in LISP. Input Functions The following table provides the most commonly used input functions of LISP − Sr.No. Function & Description…
-
Hash Table
The hash table data structure represents a collection of key-and-value pairs that are organized based on the hash code of the key. It uses the key to access the elements in the collection. A hash table is used when you need to access elements by using a key, and you can identify a useful key value. Each…
-
Tree
You can build tree data structures from cons cells, as lists of lists. To implement tree structures, you will have to design functionalities that would traverse through the cons cells, in specific order, for example, pre-order, in-order, and post-order for binary trees. Tree as List of Lists Let us consider a tree structure made up…
-
Set
Common Lisp does not provide a set data type. However, it provides number of functions that allows set operations to be performed on a list. You can add, remove, and search for items in a list, based on various criteria. You can also perform various set operations like: union, intersection, and set difference. Implementing Sets…
-
Vectors
Vectors are one-dimensional arrays, therefore a subtype of array. Vectors and lists are collectively called sequences. Therefore all sequence generic functions and array functions we have discussed so far, work on vectors. Creating Vectors The vector function allows you to make fixed-size vectors with specific values. It takes any number of arguments and returns a…