Advertisement
Guest User

Untitled

a guest
Apr 18th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. 5.
  2.  
  3. (defun izbrisi (x L)
  4. (cond
  5. ((null L) nil)
  6. ((and (atom (car L)) (not (eq (car L) x))) (cons (car L) (izbrisi x (cdr L))))
  7. ((and (atom (car L)) (eq (car L) x)) (izbrisi x (cdr L)))
  8. ((listp (car L)) (cons (izbrisi x (car L)) (izbrisi x (cdr L))))
  9. )
  10.  
  11. )
  12.  
  13. --------------------------------------
  14. 6.
  15. (defun atomi(lista)
  16. (if (null lista) nil
  17. (if (listp (car lista))
  18. (append (atomi (car lista)) (atomi (cdr lista)))
  19. (cons (car lista) (atomi (cdr lista)))
  20. )
  21. )
  22. )
  23.  
  24. (defun broj_pom(el lista pom)
  25. (if (null lista) 0
  26. (if (eq (car lista) el) pom
  27.  
  28. (broj_pom el (cdr lista) (+ 1 pom))
  29. )
  30. )
  31. )
  32.  
  33. (defun redenbr(x L)
  34. (setq list (atomi L))
  35. (broj_pom x list 1)
  36. )
  37.  
  38.  
  39. ------------------------------------------
  40. 7.
  41. (defun otstraniNp (n lista pom)
  42. (
  43. cond
  44. ((null lista) nil)
  45. ((eq n pom) (otstraniNp n (cdr lista) (+ 1 pom)))
  46. ((listp (car lista)) (cons (otstraniNp n (car lista) 1) (otstraniNp n (cdr lista) (+ 1 pom))))
  47. (t (cons (car lista) (otstraniNp n (cdr lista) (+ 1 pom))))
  48.  
  49. )
  50.  
  51. )
  52. (defun otstraniN (n L)
  53. (otstraniNp n L 1)
  54.  
  55. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement