1 / 6

JAZYKY U MELEJ I NTELIGENCIE

JAZYKY U MELEJ I NTELIGENCIE. Common LISP Funkcie vyššieho rádu Marian.Mach @ tuke.sk http ://neuron.tuke.sk/~machm Febru ár , 2011. Vyhodnotenie funkcie. (defun avg3 (a b c) (/ (+ a b c) 3)) (setf qq (function avg3)) (avg3 2 3 4) (funcall #’avg3 2 3 4) (funcall qq 2 3 4)

kelvin
Download Presentation

JAZYKY U MELEJ I NTELIGENCIE

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JAZYKY UMELEJ INTELIGENCIE Common LISP Funkcie vyššieho rádu Marian.Mach@tuke.sk http://neuron.tuke.sk/~machm Február, 2011 Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach

  2. Vyhodnotenie funkcie • (defun avg3 (a b c) (/ (+ a b c) 3)) • (setf qq (function avg3)) • (avg3 2 3 4) • (funcall #’avg3 2 3 4) • (funcall qq 2 3 4) • (funcall #’(lambda (a b c) (/ (+ a b c) 3)) 2 3 4) • (apply #’+ ‘(2 3 4 5)) • (apply #’+ 2 3 ‘(4 5)) Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach

  3. Testovanie s predikátom • (every #’(lambda (x) (evenp (print x))) ‘(2 4 6)) • (every #’(lambda (x) (evenp (print x))) ‘(2 3 4)) • (every #’< ‘(2 3 4) ‘(3 4 5 6) ‘(4 5 6 7 8)) • (some #’(lambda (x) (evenp (print x))) ‘(3 4 5)) • (some #’(lambda (x) (evenp (print x))) ‘(3 5 7)) • (notevery #’(lambda (x) (evenp (print x))) ‘(2 3 4)) • (notevery #’(lambda (x) (evenp (print x))) ‘(2 4 6)) • (notany #’(lambda (x) (evenp (print x))) ‘(2 3 4)) • (notany #’(lambda (x) (evenp (print x))) ‘(3 5 7)) Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach

  4. Spracovanie zoznamu/sekvencie • (member-if #'evenp '(1 2 3)) • (member-if-not #'evenp '(1 2 3)) • (member-if #'evenp '(1 2 3) :key #'1+) • (remove-if #'oddp '(1 2 3 4 5)) • (remove-if-not #'oddp '(1 2 3 4 5)) • (remove-if #'oddp '(1 2 3 4 5) :key #’1+) • (remove-if (complement #'oddp) ‘(1 2 3 4 5)) Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach

  5. Redukcia zoznamu • (reduce #'list '(1 2 3)) • (reduce #'list '(1 2 3) :initial-value 0) • (reduce #'list '(1 2 3) :from-end t) • (reduce #'list '(1 2 3) :start 1) • (reduce #'list '(1 2 3) :end 2) Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach

  6. Mapovanie zoznamu • (mapcar #'- '(1 2 3)) • (mapcar #'+ '(1 2 3) '(12 12)) • (mapc #'(lambda (x) (print (- x))) '(1 2 3)) • (maplist #'append '(1 2 3) '(a b)) • (mapl #'(lambda (x) (print (length x))) '(1 2 3)) Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach

More Related