Lisp - Built-in Functions



LISP, especially Common LISP dialect, has a rich set of built-in functions covering a wide range of operations. In this chapter, we're listing down key catogories of functions in LISP.

LISP Manipulation

  • car − returns first element of the list.

  • cdr − returns rest of the list, excluding first element of the list.

  • cons − creates a new list by adding an element to the beginning of the list.

  • list − creates a new list of its arguments.

  • append − concatenates lists.

  • member − checks if an element is part of a list.

Airthmetic Operations

  • + − Addition of arguments.

  • - − Subtraction of arguments.

  • * − Multiplication of arguments

  • / − Division of arguments

  • mod − Remainder of division of arguments

  • max − Maximum of arguments

  • min − Minimum of arguments

Predicates

  • = − Equality checks on numbers

  • eq − Identity comparison

  • eql − Deep equality check

  • atom − Check on argument as atom, not a list

  • listp − To check if argument is a list

  • null − To check if list is empty

  • numberp − To check if argument is a number

Control Flow

  • if − For conditional evaluation

  • cond − For multiple conditions

  • let − To create local variables

  • defvar − To create global variables

  • do − To create a loop

I/O

  • print − prints expression to console

  • write − write expression to console

  • read − to read an expression from console

Functions Definition

  • defun − to define a function

  • lambda − to create an anonymous function

Apart from rich set of functions, LISP provides macros to extend the programming language.

Advertisements