Escolar Documentos
Profissional Documentos
Cultura Documentos
Sintaxis y Semántica
Compiladores e interpretes
Lenguajes script Medio Curso
Lenguajes funcionales 22/03/2018
Lenguajes lógicos
Lenguajes imperativos
Ordinario
Lenguajes Orientados a 06/06/2018
Objetos
Extrardinario
19/06/2018
• Lenguajes Script: JavaScript, Python, Perl.
Tareas (4) 40 (8 + 2)
Examen Ordinario 20
Producto Integrador 20
Cont act o
Dudas: dudassz@hotmail.com
Asunto:Materia.
Tareas: uanlfimerszptar@hotmail.com
Asunto:Materia,Hora, # Tarea,Matrícula o Color.
• Fechas de entrega de tareas
Tarea 1 – 09 Abril
Tarea 2 - 09 Abril
Tarea 3 – 18 de Mayo
Tarea 4 – 06 de Junio
• JavaScript for Absolute Beginners
• Terry McNavage
• https://link.springer.com/book/10.1007/978-1-4302-
7218-2
• Beginning Python
• From Novice to Professional
• Magnus Lie Hetland
• https://link.springer.com/book/10.1007/978-1-4302-
0072-7
• Beginning Perl
• James Lee
• https://link.springer.com/book/10.1007/978-1-4302-
2794-6
• Practical Common Lisp
• Peter Seibel
• https://link.springer.com/boo
k/10.1007/978-1-4302-0017-8
• Introduction to Programming
with Fortran
• With Coverage of Fortran 90,
95, 2003, 2008 and 77
• Ian Chivers
• Jane Sleightholme
• https://link.springer.com/boo
k/10.1007/978-3-319-17701-4
Lenguajes de Programación
Introducción, Compiladores e Interpretes
• Ejemplo:
• let f x = x + 3
Ámbito estático
• El alcance de las ligas sigue la estructura sintáctica del programa.
• if (expression){
•…
•}
• if (expression){
• …
• }else{
• …
• }
Switch
• switch (expression)
• {
• case condition 1: statement(s)
• break;
• case condition 2: statement(s)
• break;
• ...
• case condition n: statement(s)
• break;
• default: statement(s)
• }
While
• while (expresión){
•…
•}
• do{
• …;
• } while (expresión);
For
• for(count = 0; count < 10; count++){
• document.write(“Contador: " + count );
•}
Funciones
• function functionname(parameter-list)
•{
•…
•}
Arreglos.
• var iceCream = [ "Chocolate Fudge Brownie", "Half Baked" ];
• Actividad 1 : MCM/JS
Lenguajes de Programación
Python
M.C Said Zamora
Compilador online
• http://pythonspot.com/run.php
• http://codepad.org/
• http://www.codeskulptor.org/
Mensajes y números
• print("Hello Hi!")
•x=3
• f = 3.1415926
• name = "Python“
• big = 358315791L
• z = complex(2,3)
•
• # Comentario
Operadores
• Aritmeticos: + * / -
• Relacionales: = , ==
Entrada
• x = int(raw_input(“Introduzca x:"))
• y = int(raw_input(“Introduzca y:"))
•
• sum = x + y
• print(sum)
Strings
• s = "Hello Python"
• print(s)
• print(s[0])
• print(s[1])
• print(s[2:4])
• print(s[6:])
Listas
• l = [ "Derpina", "Derp", "Derpette" ]
• print l
• print l[0]
• print l[1]
• l.append("")
• l.remove("")
• l.sort()
• l.reverse()
Tuplés
• tuple = ()
• tuple = (3,)
• persInfo = ("Diana", 32, “Chiapas")
• nom,edad,pais,carrera = ('Diana',32,’Mexico','Comp')
• x = (3,4,5,6)
• x = x + (1,2,3)
Condicionales
• if ( ):
• Elif( ):
• Else:
for
• words = ['cat', 'window', 'defenestrate']
• >>> for w in words:
• print(w, len(w))
• range()
Funciones
• def nombre( ):
Lenguajes de Programación
Perl
M.C Said Zamora
• # Comentario
• Print “Mensaje”;
Identificadores
• $ Escalar
• @ Arreglo
• % Tabla hash
• $edad = 25;
• $nombre= "John Paul";
Arreglos y tablas Hash
• @edades = (25, 30, 40);
• @nombres = ("John Paul", "Lisa", "Kumar");
• @copia = @nombres;
• $tamaño = @nombres;
Operadores escalares
• $str = "hello" . “hi”;
• $num = 5 + 10;
• $mul = 4 * 5;
• print "$dia[0]\n";
• @var_20 = (10..20);
• @var_abc = (a..z);
• push (@ARRAY, LIST)
• @weekdays = @days[3,4,5];
Tabla Hash
• $data{'John Paul'} = 45;
• $data{'Lisa'} = 30;
• $data{'Kumar'} = 40;
• %data = (-JohnPaul => 45, -Lisa => 30, -Kumar => 40);
• delete $data{'Ali'};
If
• $status = ($age > 60 )?
• if(){
•}
• if(){
• }else{
•
•}
While / For
• while()
•{
•;
•}
• nom( arg );
Lenguajes de Programación
Lenguajes funcionales: LISP
M.C Said Zamora
Expresiones
• LISP evalúa expresiones definidas por el usuario.
• USER(3): (double 3)
Recursividad
• (defun factorial (N)
• “Factorial de N."
• (if (= N 1)
• 1
• (* N (factorial (- N 1)))))
Operadores relacionales
• (= x y)
• (/= x y)
• (< x y)
• (> x y)
• (<= x y)
• (>= x y)
Recursividad múltiple
• (defun fibonacci (N)
• "N‘ numero de Fibonacci."
• (if (or (zerop N) (= N 1))
• 1
• (+ (fibonacci (- N 1)) (fibonacci (- N 2)))))
• Zerop es un predicado.
Operadores lógicos y funciones predefinidas
• (1+ x) (+ x 1)
• (1- x) (- x 1)
• (zerop x) (= x 0)
• (plusp x) (> x 0)
• (minusp x) (< x 0)
• (evenp x) (= (rem x 2) 0)
• (oddp x) (/= (rem x 2) 0)
• Constructor
• Selector
• Reconocedor
Constructores
• Nil
• (cons x L)
• (quote (2 3 5 7 11 13 17 19))
• '(2 3 5 7 11 13 17 19)
Selectores
• (first '(2 4 8))
• (if (null L)
• 0
• (1+ (recursive-list-length (rest L)))))
• USER(40): (trace recursive-list-length)
• (RECURSIVE-LIST-LENGTH)
• USER(41): (recursive-list-length '(2 3 5 7 11 13 17 19))
• 0: (RECURSIVE-LIST-LENGTH (2 3 5 7 11 13 17 19))
• 1: (RECURSIVE-LIST-LENGTH (3 5 7 11 13 17 19))
• 2: (RECURSIVE-LIST-LENGTH (5 7 11 13 17 19))
• 3: (RECURSIVE-LIST-LENGTH (7 11 13 17 19))
• 4: (RECURSIVE-LIST-LENGTH (11 13 17 19))
• 5: (RECURSIVE-LIST-LENGTH (13 17 19))
• 6: (RECURSIVE-LIST-LENGTH (17 19))
• 7: (RECURSIVE-LIST-LENGTH (19))
• 8: (RECURSIVE-LIST-LENGTH NIL)
• 8: returned 0
• 7: returned 1
• 6: returned 2
• 5: returned 3
• 4: returned 4
• 3: returned 5
• 2: returned 6
• 1: returned 7
• 0: returned 8
• 8
Símbolos
• No diferencia mayúsculas y minúsculas
• `t = t
Enésimo
• USER(59): (nth 0 '(a b c d))
•A
• USER(60): (nth 2 '(a b c d))
•C
Member
• USER(64): (member 'b '(hola)) ;
• NIL
• USER(65): (member ‘y '( y hola)) ;
• ‘(y hola)
• (= x y)
• (eq x y)
• (eql x y)
• (equal x y)
• (equalp x y)
Reverse L
• USER(1): (reverse '(1 2 3 4))
• (4 3 2 1)
• USER(2): (reverse '(1 (a b) (c d) 4))
• (4 (c d) (a b) 1)
• USER(3): (reverse nil)
• NIL
Estado del programa, variables.
• (defparameter * contador * 0)
• (defparameter *umbral* 4)
• (defun contador ()
• (if (>= (1+ *contador*) * umbral *)
• (setf * contador * 0)
• (setf * contador * (1+ * contador *))))
• (defun valor ()
• *counter*)
• (defun valorumbral ()
• *umbral*)