JAZYKY UMELEJ INTELIGENCIE Common LISP Riadenie procesnho toku

  • Slides: 12
Download presentation
JAZYKY UMELEJ INTELIGENCIE Common LISP Riadenie procesného toku Marian. Mach@tuke. sk http: //neuron. tuke.

JAZYKY UMELEJ INTELIGENCIE Common LISP Riadenie procesného toku Marian. Mach@tuke. sk http: //neuron. tuke. sk/~machm Február, 2011 Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach 1

Sekvencia (progn 1 2 3 4) § (let () 1 2 3 4) §

Sekvencia (progn 1 2 3 4) § (let () 1 2 3 4) § Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach 2

Vetvenie (if (< 3 4) 4 3) § (if (> 3 4) 4 3)

Vetvenie (if (< 3 4) 4 3) § (if (> 3 4) 4 3) § (if (/= 3 0) 3) § (if (= 3 0) 3) § (if t (progn (print "ok") 7)) § Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach 3

Vetvenie (when t (print "ok") 7) § (when (and t nil) (print "ok") 7)

Vetvenie (when t (print "ok") 7) § (when (and t nil) (print "ok") 7) § (unless (not t) (print "ok") 7) § (unless (or nil t) (print "ok") 7) § Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach 4

Vetvenie (cond ((< -1 0) (print "menej ako nula") (- -1)) (nil) (t 0))

Vetvenie (cond ((< -1 0) (print "menej ako nula") (- -1)) (nil) (t 0)) § (cond ((> -1 0) (print "menej ako nula") (- -1)) (nil) (t 0)) § (cond (nil)) § (cond) § Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach 5

Vetvenie (case (+ 3 4) (0 (print "nula") 0) (4) (t 99)) § (case

Vetvenie (case (+ 3 4) (0 (print "nula") 0) (4) (t 99)) § (case (+ 3 -3) (0 (print "nula") 0) (4) (t 99)) § (case (+ 3 1) (0 (print "nula") 0) (4) (t 99)) § Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach 6

Iterácia § (do (x (y 6) (z 0 (1+ z))) ((< y z) (print

Iterácia § (do (x (y 6) (z 0 (1+ z))) ((< y z) (print "koniec") (list x y z)) (setf x z) (decf y)) § (do* ((z 0 (1+ z)) (x z)) ((< 3 z))) Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach 7

Iterácia (dolist (x '(1 2 3 4)) (print x) (1 - x)) § (dolist

Iterácia (dolist (x '(1 2 3 4)) (print x) (1 - x)) § (dolist (x '()) (print 0)) § (dolist (x '(1 2 3 4) x) (print x) (1 - x)) § (let ((y 0)) (dolist (x '(1 2 3 4) y) (incf y x))) § (let ((y 0)) (dolist (x '(1 2 3 4)) (incf y x)) y) § (let ((y 0)) (dolist (x '(1 2 3 4) y) (incf y x)) y) § Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach 8

Iterácia (dotimes (x 5) (print x) t) § (dotimes (x 0) (print x) t)

Iterácia (dotimes (x 5) (print x) t) § (dotimes (x 0) (print x) t) § § (let ((y 0)) (dotimes (x 5 y) (incf y x))) Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach 9

Podmienečné vykonávanie (and (= 3 3) (< 4 3 5)) § (and (/= 4

Podmienečné vykonávanie (and (= 3 3) (< 4 3 5)) § (and (/= 4 3) (<= 3 4 4)) § (and 2 3 4) § (or (>= 3 4) (> 3 4)) § (or 2 3 4) § Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach 10

Otočenie podmienky (not t) § (not nil) § (not 6) § Katedra kybernetiky a

Otočenie podmienky (not t) § (not nil) § (not 6) § Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach 11

Porovnávanie (eq 'jano) § (eq 99 99) § (eq 999999999999) § (eql '(a b))

Porovnávanie (eq 'jano) § (eq 99 99) § (eq 999999999999) § (eql '(a b)) § § (equal '(a b)) § (= 2 2. 0) Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach 12