(SETQ L '(A B C D)) ;problem 1 (format t "My-first CAR") (defun my-first (lst) ( car lst) ) (print (my-first L)) (format t "~%My-rest CDR") (defun my-rest (lst) (cdr lst) ) (print(my-rest L)) (format t "~%Construct") (defun construct (lst) (cons (car lst) (cdr lst)) ) (print (construct L)) ;problem 2 (format t "~%Rotate-left") (defun rotate-left (lst) (append (CDR lst) (list(car lst))) ) (print (rotate-left L)) (format t "~%Double rotate-left") (print (rotate-left (rotate-left L))) ;problem 3 (format t "~%Rotate-right") (defun rotate-right (lst) ( append (LAST lst) (reverse (cdr(reverse lst))) ) ) (print (rotate-right L)) (format t "~%Double rotate-right") (print (rotate-right (rotate-right L))) ;problem 4 (format t "~%Palindrom") (defun palindrom (lst) (append lst (reverse lst) ) ) (print (palindrom L)) ;problem 5 (format t "~%Quadratic") (defun ec2 (a b c) (list (/(+(- b) (SQRT(-(* b b) (* 4 a c)))) (* 2 a)) (/(-(- b) (SQRT(-(* b b) (* 4 a c )))) (* 2 a))) ) (print (ec2 2 7 6))
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more