Manual basico Lisp
1. TIPOS DE DATOS:
1.1 Átomos:
CL-USER 1 > 8
8
CL-USER 2 > 'a
A
1.2 Listas:
Ingeniería
Inteligencia Artificial
; 1 elemento
; 2 elementos
2. LOS NÚMEROS Y SUSOPERACIONES:
2.1 Los números:
CL-USER 1 > 4
4
CL-USER 2 > 10
10
2.2 Operaciones matemáticas:
CL-USER 3 > (/ 9 3)
3
CL-USER 4 > (* 4 5)
20
CL-USER 5 > (+ 8 3)
11
CL-USER 6 > (*3 6 7)
126
CL-USER 7 > (MAX 4 8 2)
8
CL-USER 8 > (MIN 5 10 3)
3
CL-USER 9 > (SQRT 100)
10.0
;división
;multiplicación
;suma
;raíz cuadrada
3. ASIGNACIÓN DE VALORES EN LISP:3.1 SETQ:
CL-USER 1 > (setq x 6)
; x=6
6
CL-USER 2 > (setq n 'r)
R
CL-USER 3 > (setq lista '(bicicleta auto moto))
(BICICLETA AUTO MOTO)
3.2 SETF:
CL-USER 1 > (setf y 2)
2 CL-USER 2 > (setf l 't)
T
4. FUNCIONES PRIMITIVAS:
4.1 Constructores de listas:
(CONS X Y)
CL-USER 1 > (cons 'p 'q)
(P . Q)
CL-USER 2 > (cons 'p '(q r))
(P Q R)
CL-USER 3 > (cons 'p(cons 'q (cons 'r())))
(P Q R)
(LIST X-1 .. X-N)
CL-USER 1 > (list 'p 'q 'r)
(P Q R)
CL-USER 2 > (list '(p q) '(r s))
((P Q) (R S))
CL-USER 3 > (list)
NIL
(APPEND L-1 … L-N)
CL-USER 1 > (append '(p) '(q) '(r s) '(t u))
(P Q R S T U)
4.2 Asignación de listas:
(CAR x/FIRST x)
CL-USER 1 > (car '(a b c))
A
CL-USER 2 > (car '((Facultad de Ingenieria) de Sistemas))(FACULTAD DE INGENIERIA)
CL-USER 3 > (first '(1 2 3))
1
(CDR x/ REST x)
CL-USER 1 > (cdr '(a b c))
(B C)
CL-USER 2 > (rest '((a b) c d))
(C D)
5. PREDICADOS DE TIPOS:
(ATOM x) CL-USER 7 > (atom 'a)
T
CL-USER 8 > (atom '(1 2))
NIL
(SYMBOLP x)
CL-USER 1 > (symbolp 'auto)
T
CL-USER 2 > (symbolp 1)
NIL
(NUMBERP x)
CL-USER 1 > (numberp 10)
T
CL-USER2 > (numberp 'numero)
NIL
(CONSP x)
CL-USER 1 > (consp '(a b))
T
CL-USER 2 > (consp nil)
NIL
CL-USER 3 > (consp '())
NIL
(NULL x)
CL-USER 1 > (null '(a b c))
NIL
6....
Regístrate para leer el documento completo.