0% found this document useful (0 votes)
53 views10 pages

Desarrollo de Los Ejercicios Propuestos en El Laboratorio: Software Lispworks

This document provides examples of commands and functions in the LispWorks software. It demonstrates how to use SETQ to assign values to variables, QUOTE to quote symbols and lists, CAR and CDR to access elements of lists, CONS to construct lists, arithmetic functions like +, -, *, /, and square root, and list functions like FIRST, REST, ENDP, REVERSE, CONS, and APPEND. Each code example is presented with the input and output in the LispWorks environment.

Uploaded by

anon_405956374
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views10 pages

Desarrollo de Los Ejercicios Propuestos en El Laboratorio: Software Lispworks

This document provides examples of commands and functions in the LispWorks software. It demonstrates how to use SETQ to assign values to variables, QUOTE to quote symbols and lists, CAR and CDR to access elements of lists, CONS to construct lists, arithmetic functions like +, -, *, /, and square root, and list functions like FIRST, REST, ENDP, REVERSE, CONS, and APPEND. Each code example is presented with the input and output in the LispWorks environment.

Uploaded by

anon_405956374
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Santos Roman, Jhunely Hilari | Sistemas

Expertos | 06/05/2015

Desarrollo De Los
Ejercicios
Propuestos en el
Laboratorio
SOFTWARE LISPWORKS

COMANDOS DE LISPWORKS
SET SETQ:
Ejemplos:

CL-USER
30
CL-USER
50
CL-USER
36
CL-USER
25
CL-USER
33
CL-USER
5
CL-USER
0
CL-USER
15
CL-USER
14
CL-USER
4
CL-USER
54
CL-USER
6
CL-USER
24
CL-USER
-7
CL-USER
-4
CL-USER
-9
CL-USER
39
CL-USER
30

1 > (setq N 30)


2 > (setq Peso 50)
3 > (setq M (+30 6))
4 > (setq Peso 50)
5 > (setq R (- 45 12))
6 > (set

'I

(- 10

7 > (set

'L

(- 5

5))
5))

8> (set 'J (- 25 10))


9> (setq / (- 20 6))
10 > (setq / (- 10 6))
11 > (setq / (- 60 6))
12 > (setq / (- 12 6))
13> (setq / (- 30 6))
14 > (setq / (- -10 -3))
15 > (setq / (+ -8 4 ))
16 > (set 'S (- 6 15))
17 > (set 'J (* -13 -3))
18 > (set 'W (* -10 -3))
PGINA 1

CL-USER 19> (set 'Z (* -13 10))


-130
CL-USER 20> (set 'M (/ 15 3))
5

QUOTE / ATOM /CDR / CONS


Ejemplos:

CL-USER 1 > (quote(Practicando en LispWorks))


(PRACTICANDO EN LISPWORKS)
CL-USER 2 > (quote (Jhunely Hilari))
(JHUNELY HILARI)
CL-USER 3 > (quote "Santos Roman")
"Santos Roman"
CL-USER 4 > (car (quote(solo muestra el primer
atomo)))
SOLO
CL-USER 5 > (car(quote((La vida es bella))))
(LA VIDA ES BELLA)

CL-USER 6 > (atom(quote ABCD))


T

CL-USER
NIL
CL-USER
NIL
CL-USER
T
CL-USER
NIL

CL-USER 11 > (cdr '(Hola Yo nac en la ciudad de


Nazca))
(YO NAC EN LA CIUDAD DE NAZCA)
CL-USER 12 > (cdr ' (- 5 2))
(5 2)

7 > (atom(quote(luna llena)))


8 > (atom(cdr '(jhuu santos)))
9 > (atom(cdr '((la casa es grande))))
10 > (atom(quote(Sistemas Expertos)))

PGINA 2

CL-USER 13 > (cdr ' (- 10000))


(10000)
CL-USER 14 > (cdr ' (Mayo excelente mes))
EXCELENTE MES
CL-USER 15 > (cdr ' ( + Amor - Odio))
AMOR - ODIO

CL-USER 16 > (cons 'beber 'tomar)


(BEBER . TOMAR)
CL-USER 17 > (* (print(+ 2 3)) (print 4))
4
20
5
CL-USER 18 > (cons 'm 'p)
(M . P)
CL-USER 19> (cons 1 8)
(1 . 8)
CL-USER 20> (cons nil nil)
(NIL)
CL-USER 21> (cons 'la '(inteligencia artificial))
(LA INTELIGENCIA ARTIFICIAL)

Funciones Primitivas
Ejemplos:

CL-USER
300
CL-USER
20
CL-USER
60
CL-USER
100
CL-USER
5.0
CL-USER

1 > (* (+ 2 3) (/ 8 2) 15)
2> (* (+ 2 3) (/ 8 2))
3 > (* (/ 8 2) 15)
4> (* (+ 2 3) 20)
5 > sqrt (* (+ 2 3) (/ 10 2))
6> sqrt (* (+ 2 3) (/ 8 2) 15)
PGINA 3

17.320509
CL-USER 7> (+ 10 20 30 40 50 60 1010)
1220
CL-USER 8> (* (+ 2526 3) (/ 8260 2))
10444770
CL-USER 9> (* (+ 12 3) (/ 8 2) 150)
9000
CL-USER 10> (*(/ 170 2)3)
255

CL-USER 11 > (quote


(+ (- 5 2) (* 3 3))
CL-USER 12 > (quote
(+ (- 5 2))
CL-USER 13 > (quote
(* (- 5 2) (* 3 3))
CL-USER 14 > (quote
(+ (- 100 2) (* 3 3))
CL-USER 15 > (quote
(+ (- 5 21) (* 13 3))

CL-USER 16 > (list 'reloj 'brazalete 'collar)


(RELOJ BRAZALETE COLLAR)
CL-USER 17 > (list '( (* 12 1) w))
(((* 12 1) W))
CL-USER 18> (list '(* 12512 ))
((* 12512))
CL-USER 19> (list '(+ 12 12 ))
((+ 12 12))
CL-USER 20> (list '(**** 12 12 ))
((**** 12 12))
CL-USER 21 > (list 'A 'D 'N)
(A D N)
CL-USER 22 > (list 'ojo 'boca 'nariz)
(OJO BOCA NARIZ)
CL-USER 23 > (list '1 '3 '5)
(1 3 5)
CL-USER 24 > (list 'la 'le 'li)
(LA LE LI)
CL-USER 25 > (list '12j '12E '12G)
(|12J| |12E| |12G|)

(+ (- 5 2) (* 3 3)))
(+ (- 5 2)))
(* (- 5 2) (* 3 3)))
(+ (- 100 2) (* 3 3)))
(+ (- 5 21) (*13 3)))

PGINA 4

Asignacin / Evaluacin de Listas


Ejemplos:

CL-USER
50
CL-USER
20
CL-USER
10
CL-USER
10

1 > (setf A 50)

CL-USER 5 > setf K (* 10 p)


100
CL-USER 6 > setf l (/ 10 R)
1
CL-USER 7> max 12 14 15 16
16
CL-USER 8> min 13 5 6 7 93 12 90.5 90.6
5
CL-USER 9 > expt 5 9
1953125
CL-USER 10> expt 36 0.5
6.0
CL-USER 11 > expt 125 (/ 1 3 )
5.0
CL-USER 12> min 10 20 30 80
10
CL-USER 13 > expt 4 11
4194304
CL-USER 14> max 125 458 524 654 111
654
CL-USER 15 > setf j (/ 100 10)
10
CL-USER 16 > setf h (+ 70 j)
80
CL-USER 17 > setf u (- 10 h)
-70
CL-USER 18 > setf n (* 5 u)
-350
CL-USER 19 > setf e (/ n 10)
-35
CL-USER 20 > setf y (* 1 e)

2 > (setf B 20)


3 > setf p (/ A 5)
4 > setf R (/ B 2)

PGINA 5

-35

FIRST / REST / ENDP / EQ / REVERSE


Ejemplos:

CL-USER 1 > first '( 1 2 3 4 5 )


1
CL-USER 2 > first ( rest '( 4 b c d 5 ))
B
CL-USER 3 > first ( rest (rest ( j h u n e l y )))
U
CL-USER 4 > (first '((abc) a b c))
(ABC)
CL-USER 5 > (first '( (a (ab) v b) b c))
(A (AB) V B)
CL-USER 6 > (rest '( (234) addf (axd)))
(ADDF (AXD))
CL-USER 7 > (rest '( (xyz) a b (aa) c))
(A B (AA) C)
CL-USER 8 > (rest ' ( (100 10 1 ) 12 23 (34)))
(12 23 (34))
CL-USER 9 > (rest ' (100 10))
(10)
CL-USER 10 > (rest ' ( 199 88 999 99 9 ))
(88 999 99 9)

CL-USER
NIL
CL-USER
T
CL-USER
NIL
CL-USER
T
CL-USER
0
CL-USER
UNICA
CL-USER
(679)
CL-USER

11 > endp '(hola no )


12> endp ( rest '(JHU))
13 > eq 3 4
14 > eq 'jhu 'jhu
15 > (first '( 0 2 4 6 8))
16 > (first '(Unica SLG))
17 > (rest '( 133 679 ))
18 > (rest '(eres unico ))
PGINA 6

(UNICO)
CL-USER 19 > (rest '(Jhunely Hilari Santos Roman))
(HILARI SANTOS ROMANI)
CL-USER 20 > eq 'jhuu 'jhu
NILL

CONS/ APPEND
Ejemplos:

CL-USER 1 > (cons 'm 'b a)


(M . B. A)
CL-USER 2 > (cons 1 4 7)
(1 . 4. 7)
CL-USER 3 > (cons nil nil)
(NIL)
CL-USER 4 > (cons 5 (cons 6 (cons 8 (cons 8 nil))))
(5 6 8 8)
CL-USER 5 > (endp '())
T
CL-USER 6 > (cons 5 (cons 3 (cons 8 nil))))
(538)
CL-USER 7 > (endp(rest '(2)))
T
CL-USER 8 > (rest (rest '(a bc d e)))
(D E)
CL-USER 9 > (eq 'a 'a)
T
CL-USER 10 > (eq 'a 'b)
NIL
CL-USER 11 > (setq x 'hola)
HOLA
CL-USER 12 > (eq 'hola 'x)
NIL
CL-USER 14 > print '1
1
CL-USER 15 > (eq (cons 'a 'a) (cons 'a 'a))
NIL
CL-USER 16 > (setq x 'abc)
ABC
CL-USER 17 > (setq str "abc")
"abc"
CL-USER 18 > (cons 'beber 'tomar)
(BEBER . TOMAR)
PGINA 7

CL-USER 19 > (reverse str)


"cba"
CL-USER 20 > (setq x "abcd")
"abcd"
CL-USER 21 > (reverse x)
"dcba"

LAST / LENGTH / LISTP


Ejemplos:

CL-USER 1 > (last '(1 2 3))


(3)
CL-USER 2 > (first '(1 2 3))
1
CL-USER 3 > (last (rest '(1 2 3)))
(3)
CL-USER 4 > (list 'a 'b 2 1)
(A B 2 1)
CL-USER 5 > (list 'a 'b 'c)
(A B C)
CL-USER 6 > (list 'a '(b) '(c))
(A (B) (C))
CL-USER 7 > (list 'h 'o 'l 'a (sqrt 4) (/ (expt 5 2) 5))
(H O L A 2.0 5)
CL-USER 8> (setq mostrar '(hilari))
(HILARI)
CL-USER 9 > (length '( a b c d))
4
CL-USER 10 > (length '( hilari))
1
CL-USER 11 > (length '( hilari (o)))
2
CL-USER 12 > (length '( hilari (o) jhu))
3
CL-USER 13 > (length '( hilari (o) jhu a))
4
CL-USER 14 > (setq str "abcd")
"abcd"
CL-USER 15 > (length srta)
4
CL-USER 16> (listp nil)
T
CL-USER 17 > (listp'())
PGINA 8

T
CL-USER 18 > (listp 'a)
NIL
CL-USER 19 > (listp '(abcd))
T
CL-USER 20 > (listp 'abcd)
NIL

PGINA 9

You might also like