1 / 10

JAZYKY U MELEJ I NTELIGENCIE

JAZYKY U MELEJ I NTELIGENCIE. Common LISP Zoznamy Marian.Mach @ tuke.sk http ://neuron.tuke.sk/~machm Febru ár , 2011. Vytvorenie zoznamu. (list 1 2 3 4) (list ' (1 2 3 4)) (list) (list 1 (list 2 3) (list) (list 4)) (make-list 4) (make-list 4 :initial-element 2)

tassos
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 Zoznamy Marian.Mach@tuke.sk http://neuron.tuke.sk/~machm Február, 2011 Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach

  2. Vytvorenie zoznamu • (list 1 2 3 4) • (list '(1 2 3 4)) • (list) • (list 1 (list 2 3) (list) (list 4)) • (make-list 4) • (make-list 4 :initial-element 2) • (setf x (list 1 2 3)) • (copy-list x) Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach

  3. Testovanie zoznamov • (listp '(1 2 3)) • (listp nil) • (listp 'jano) • (listp 3) • (null '(1 2 3)) • (null '()) • (equal '(1 2) (list 1 2)) Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach

  4. Rozoberanie zoznamu • (car '(1 (2 3) NIL (4))) • (cdr '(1 (2 3) NIL (4))) • (cdr '(1)) • (car nil) • (cdr nil) • (car (cdr (car (cdr '(1 (2 3) NIL (4)))))) • (cadadr '(1 (2 3) NIL (4))) Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach

  5. Alternatíva k car a cdr • (first '(1 (2 3) NIL (4))) = car • (second '(1 (2 3) NIL (4))) = cadr • (third '(1 (2 3) NIL (4))) = caddr • … • (tenth '(1 (2 3) NIL (4))) • (rest '(1 (2 3) NIL (4))) = cdr Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach

  6. Zovšeobecnené rozoberanie spredu • (nth 0 '(1 2 3)) = car • (nth 3 '(1 2 3)) • (nthcdr 0 '(1 2 3)) • (nthcdr 1 '(1 2 3)) = cdr • (nthcdr 3 '(1 2 3)) Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach

  7. Zovšeobecnené rozoberanie zozadu • (last '(1 2 3)) = nthcdr (dlz-1) • (last '()) • (last '(1 2 3) 2) = nthcdr (dlz-2) • (last '(1 2 3) 0) = nthcdr (dlz-0) • (butlast '(1 2 3)) • (butlast '(1 2 3) 2) Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach

  8. Rozširovanie zoznamu • (cons 1 '(2 3)) • (cons 1 nil) • (cons '(1 2) '(3 4)) • (append '(1 2) '(3 4) '(5 6)) • (append '(1 2) nil '(5 6)) • (append) • (list-length '(1 2 3)) Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach

  9. Hľadanie prvku • (member 2 '(1 2 3)) • (member 2 '(1 4 3)) • (member '(2) '((1) (2) (3)) ) • (member '(2) '((1) (2) (3)) :test #'equal) • (member 2 '((a 1) (b 2) (c 3)) :key #'cadr) Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach

  10. Rôzne užitočné funkcie • (remove 2 '(1 2 3 2 1)) seq • (remove 2 '(1 2 3 2 1) :count 1 :from-end t) • (remove 2 '(1 2 3 4 5) :start 1 :end 2) • (remove 2 '((1 3) (3 1)) :test #'< :key #'car) • (reverse '(1 2 3)) seq • (length '(1 2 3)) seq • (subseq '(1 2 3 4) 1) seq • (subseq '(1 2 3 4) 1 3) Katedra kybernetiky a umelej inteligencie FEI, TU v Košiciach

More Related