(defun soma (a b c)
(+ a b c))
(defun quadrado(a)
(* a a))
(defun tamanho(lst)
(if (null lst)
0
(+1 (tamanho (cdr lst)))))
(defun enesimo(lst n)
(if (not (null lst))
(if (= l)
(car lst)
(enesimo (cdr lst) (-n 1)))))
(defun inverter (lst)
(if (not (null lst))
(append (inverter (cdr lst)) (list (car lst)))))
(defun membro(e lst)
(if (not (null lst))
(or (= e (car lst)) (membro e (cdr lst)))))
(defun soma (a b c)
(+ a b c))
(defun quadrado (a)
(* a a))
(defun media (a b)
(/ (+ a b) 2))
(defun fat (n)
(if (= n 0)
1
(* n (fat (- n 1)))))
(defun tamanho (lst)
(if (null lst)
0
(+ 1 (tamanho (cdr lst)))))
(defun enesimo (lst n)
(if (not (null lst))
(if (= n 1)
(car lst)
(enesimo (cdr lst) (- n 1)))))
(defun inverter (lst)
(if (not (null lst))
(append (inverter (cdr lst)) (list (car lst)))))
(defun membro (e lst)
(if (not (null lst))
(or (equal e (car lst)) (membro e (cdr lst)))))
(defun oco (a lst)
(if (null lst)
0
(if (equal a (car lst))
(+ 1 (oco a (cdr lst)))
(oco a (cdr lst)))))
(defun mult (e lst)
(if (not (null lst))
(cons (* e (car lst)) (mult e (cdr lst)))))
(defun conc (lst1 lst2)
(if (null lst1)
lst2
(cons (car lst1) (conc (cdr lst1) lst2))))
(defun deletar (a lst)
(if (not (null lst))
(if (eql a (car lst))
(deletar a (cdr lst))
(cons (car lst) (deletar a (cdr lst))))))
(defun tirar_ult (lst)
(if (not (null lst))
(if (not (null (cdr lst)))
(cons (car lst) (tirar_ult (cdr lst))))))
(defun ultimo (lst)
(if (not (null lst))
(if (= 1 (tamanho lst))
(car lst)
(ultimo (cdr lst)))))
(defun palindromo2 (lst)
(equal lst (inverter lst)))
(defun palindromo (lst)
(if (not (null lst))
(or (= 1 (tamanho lst))
(and (= 2 (tamanho lst))
(equal (car lst) (cadr lst)))
(and (equal (car lst) (ultimo lst))
(palindromo (tirar_ult (cdr lst)))))))
Nenhum comentário:
Postar um comentário