1 / 14

Funkcie II

Funkcie II. (defun vzdialenost (x y) (sqrt (+ (* x x) (* y y)))) (defun blizsi-bod1 (x1 y1 x2 y2) (if (< (vzdialenost x1 y1) (vzdialenost x2 y2)) :prvy :druhy)). Funkcie II. (defun blizsi-bod2 (x1 y1 x2 y2) (let ((vzdialenost (lambda (x y)

azizi
Download Presentation

Funkcie II

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. Funkcie II • (defun vzdialenost (x y) (sqrt (+ (* x x) (* y y)))) • (defun blizsi-bod1 (x1 y1 x2 y2) (if (< (vzdialenost x1 y1) (vzdialenost x2 y2)) :prvy :druhy))

  2. Funkcie II • (defun blizsi-bod2 (x1 y1 x2 y2) (let ((vzdialenost (lambda (x y) (sqrt (+ (* x x) (* y y)))))) (if (< (funcall vzdialenost x1 y1) (funcall vzdialenost x2 y2)) :prvy :druhy)))

  3. Funkcie II • (defun blizsi-bod2b (x1 y1 x2 y2) (let ((vzdialenost)) (setf (symbol-function vzdialenost) (lambda (x y) (sqrt (+ (* x x) (* y y))))) (if (< (vzdialenost x1 y1) (vzdialenost x2 y2)) :prvy :druhy)))

  4. Funkcie II • (defun blizsi-bod3 (x1 y1 x2 y2) (flet ((vzdialenost (x y) (sqrt (+ (* x x) (* y y))))) (if (< (vzdialenost x1 y1) (vzdialenost x2 y2)) :prvy :druhy)))

  5. Funkcie II • (defun sucet-aux (accum scitance) (if (null scitance) accum (sucet-aux (+ accum (first scitance)) (rest scitance)))) • (defun sucet1 (args) (sucet-aux 0 args))

  6. Funkcie II • (defun sucet2 (args) (labels ((sucet-aux (accum scitance) (if (null scitance) accum (sucet-aux (+ accum (first scitance)) (rest scitance))))) (sucet-aux 0 args)))

  7. Funkcie II • (defun sucet3 (scitance &optional (accum 0)) (if (null scitance) accum (sucet3 (rest scitance) (+ accum (first scitance)))))

  8. Funkcie II • (floor 5.5) • (+ 1 (floor 5.5)) • (print (floor 5.5))

  9. Funkcie II • (values 2 5) • (values 2 5 4 5) • (values)

  10. Funkcie II • ((lambda () ((lambda () (values 1 2))))) • (print (values))

  11. Funkcie II • (multiple-value-call #'+ (values 1 2 3)) • (multiple-value-list (values 1 2 3)) • (multiple-value-bind (x y z) (values 1 2 3) (list x y z))

  12. Funkcie II • (macroexpand `(multiple-value-list (values 1 2))) (MULTIPLE-VALUE-CALL #'LIST (VALUES 1 2))

  13. Funkcie II • (macroexpand `(multiple-value-bind (x y) (values 1 2) (list x y))) (LET* ((#:G4849 (MULTIPLE-VALUE-LIST (VALUES 1 2))) (X (POP #:G4849)) (Y (POP #:G4849))) (LIST X Y))

  14. Funkcie II • (let (x y z) (multiple-value-setq (x y z) (values 1 2)) (list x y z)) • (let (x y z) (setf (values x y z) (values 1 2 3)) (list x y z)) • (let (x y z) (setf (values x y z) (values 1 2 3 4)) (list x y z)) • (let (x y z) (setf (values x y z) (values 1 2)) (list x y z))

More Related