11. Types

Common Lisp is a dynamically and strongly typed language. This means that variables do not have a fixed type, but data types are strictly respected during execution.

Some of the most common data types in Common Lisp are:

  • Numbers: integer, float, rational, complex, and number.
  • Text strings: character and string.
  • Symbols: symbol, keyword, and null.
  • Lists: list, cons, and nil.
  • Sequences: sequence, vector, and array.
  • Hash tables: hash-table, structure-object, and standard-object.
  • Functions: function, compiled-function, and generic-function.
  • Special: t (true), nil (false or empty list), and boolean.

There are more types, but these are the ones most commonly used.

To check the type of a value, you can use predicates such as typep:

* (typep 42 'integer)
T

* (typep 3.14 'float)
T

* (typep "Hola" 'string)
T

* (typep '(a b c) 'list)
T

This work is under a Attribution-NonCommercial-NoDerivatives 4.0 International license.

Desafíos de programación atemporales y multiparadigmáticos

Desafíos de programación atemporales y multiparadigmáticos

Te encuentras ante un librillo de actividades, divididas en 2 niveles de dificultad. Te enfrentarás a los casos más comunes que te puedes encontrar en pruebas técnicas o aprender conceptos elementales de programación.

Buy the book

Will you buy me a coffee?

This is how I keep writing without ads or paywalls.

Comments

There are no comments yet.