Advertisement
Tavi33

CFLP #1

Mar 18th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 1.13 KB | None | 0 0
  1. (defun modul(a)
  2. (if (< a 0) (- a) a))
  3.  
  4. (defun neg(a)
  5. (if (< a 0) (- a) (- a)))
  6.  
  7.  
  8.  
  9.  
  10. (defun mij(a b c)
  11. (cond ((and (= (min a b c) a) (= (max a b c) c)) b)))
  12.  
  13.  
  14. (defun my-third(lista)
  15. (if (listp lista) (nth '2 lista) NIL))
  16.  
  17. (defun my-last(lista)
  18. (if (listp lista) (last lista) NIL))
  19.  
  20. (defun my-append(x y)
  21. (if (and (listp x) (listp y)) (append x y) NIL))
  22.  
  23. (defun palindrom(lista)
  24. (if (equal (reverse lista) lista) T NIL))
  25.  
  26. (defun eq(a b c)
  27. (let ((d (- (* b b) (* 4 a c))))
  28. (if (> d 0) (list (/ (+ (- b) d) (* 2 a))   (/ (- (- b) d) (* 2 a))) "Solutii complexe")))
  29.  
  30. (defun fu(x)
  31. (cond ((< x -2) (* x x)) ((= x -2) (* x x)) ((< x 1) (+ x 2)) ((= x 1) (+ x 2)) ((> x 1) (sqrt (+ (* x x) 1)))  ))
  32.  
  33. (defun fnc(a lista)
  34. (if (member a lista) (member a lista) (append lista (list a))))
  35.  
  36.  
  37. (defun meniu()
  38. (format t "1 - Adunare\n")
  39. (format t "2 - Scadere\n")
  40. (format t "3 - Inmultire\n")
  41. (format t "4 - Restul impartirii\n")
  42. (format t "Alegeti optiunea, apoi introduceti doua numere: ")
  43. (let ( (opt (read)) (x (read)) (y (read)) )
  44. (cond ((= opt 1) (+ x y)) ((= opt 2) (- x y)) ((= opt 3) (* x y)) ((= opt 4) (rem x y)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement