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, andnumber. - Text strings:
characterandstring. - Symbols:
symbol,keyword, andnull. - Lists:
list,cons, andnil. - Sequences:
sequence,vector, andarray. - Hash tables:
hash-table,structure-object, andstandard-object. - Functions:
function,compiled-function, andgeneric-function. - Special:
t(true),nil(false or empty list), andboolean.
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
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 bookWill you buy me a coffee?
This is how I keep writing without ads or paywalls.
Sure, it's on me!
Comments
There are no comments yet.