Common Lisp: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 15:
(setq pi 3.1415) ; sets the variable "pi" equal to 3.1415
 
; Define a function that squares a number
''(more needed)''
(defun square (x) (* x x))
; Execute the function
(square 3) ; Returns "9"
 
===Data types===
Line 37 ⟶ 40:
 
====Functions====
In Common Lisp, ''functions'' are a data type. For instance, it is possible to write functions that take other functions as arguments. This makes it possible to make very general operations. An example of this is the ''sort'' function, which can sort many types of data in a variety of ways.
In Common Lisp, ''functions'' are a data type. ''(details needed)''
 
''Check that these examples are right, please...''
 
(sort '(5 2 6 3 1 4)) ; Returns (1 2 3 4 5 6)
(sort '(5 2 6 3 1 4) #'>) ; Returns (6 5 4 3 2 1), using the > function as
; the comparison operator
(sort '(#\c #\a #\d #\r)) #'char<)
; Returns (#\a #\c #\d #\r)
 
====Other types====