Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Zad 1:
- (defun stepe (n m)
- (if (eq m 1)
- n
- (* n (stepe n (- m 1))))
- )
- (stepe 4 2)
- ;Zad 2:
- (defun suma (zbir dokj n)
- (if (eq n dokj)
- zbir
- (suma (+ zbir (+ dokj 1)) (+ dokj 1) n))
- )
- (suma 0 0 5)
- ;Zad 3:
- (defun grdasuma (zbir zbirs dokj n)
- (if (eq (+ n 1) dokj)
- zbir
- (grdasuma (+ zbir (+ zbirs dokj )) (+ zbirs dokj) (+ dokj 1) n))
- )
- (grdasuma 0 0 1 4)
- ;Zad 4:
- (defun nepbr (l)
- (pomosna '() l)
- )
- (defun pomosna (noval l)
- (if (null l)
- noval
- (if (= (mod (car l) 2) 1)
- (pomosna (append noval (list (car l))) (cdr l))
- (pomosna noval (cdr l))
- )
- )
- )
- (nepbr '(1 2 -3))
- ;pusi k
- ;Zad 5:
- (defun brpodlisti (l)
- (pomosna 0 l)
- )
- (defun pomosna (brojac l)
- (if (null l)
- brojac
- (if (listp (car l))
- (pomosna (+ brojac 1) (cdr l))
- (pomosna brojac (cdr l))
- )
- )
- )
- (brpodlisti '(1 '(2) '(-3)))
- ;Zad 6:
- (defun br_atom (l)
- (pomosna 0 l)
- )
- (defun pomosna (brojac l)
- (if (null l)
- brojac
- (if (atom (car l))
- (pomosna (+ brojac 1) (cdr l))
- (pomosna (+ brojac (pomosna 0 (car l))) (cdr l))
- )
- )
- )
- (br_atom '(a 4 (ana 9 m) 6 7))
- ;Zad 7:
- (defun br_atom (l)
- (pomosna '() l)
- )
- (defun pomosna (noval l)
- (if (null l)
- noval
- (cond
- ((numberp (car l)) (pomosna (append noval (list (car l))) (cdr l)))
- ((atom (car l)) (pomosna noval (cdr l)))
- ((listp (car l)) (pomosna (append noval (pomosna noval (car l))) (cdr l)))
- )
- )
- )
- (br_atom '(a (1 2) 4 c))
- ;Mala 8ma Zad:
- (defun otstraniN (l n)
- (pomosna '() l n)
- )
- (defun pomosna (noval l n)
- (if (= n 1)
- (append noval (cdr l))
- (pomosna (append noval (list (car l))) (cdr l) (- n 1))
- )
- )
- (otstraniN '(1 2 3 4 5 6 7) 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement