Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.70 KB | None | 0 0
  1. ;gnu clisp 2.49
  2.  
  3. (defun prvek (L X)
  4.     (cond ( (null L) () )
  5.           ( (atom (car L))(or (= (car L) X) (prvek (cdr L) X)) )
  6.           ( t (or (prvek (cdr L) X) (prvek (car L) X)) )
  7.     )
  8. )
  9.  
  10. ;(print (prvek '(1 2 (3)) 3))
  11.  
  12. (defun pocet (L)
  13.     (cond ( (null L) 0 )
  14.           ( t  (+ 1 (pocet (cdr L))) )
  15.     )
  16. )
  17.  
  18. ;(print (pocet '(1 2 3 4)))
  19.  
  20. (defun pocet2 (L)
  21.     (cond ( (null L) 0 )
  22.           ( (atom (car L)) (+ 1 (pocet2 (cdr L))) )
  23.           ( t (+ (pocet (car L)) (pocet(cdr L))) )
  24.     )
  25. )
  26.  
  27. ;(print (pocet2 '(1 2 (3 4) 5 6)))
  28.  
  29. (defun pocet3(L)
  30.   (cond
  31.     ((null L) 0)
  32.     ((atom L) 1)
  33.     (t (+ (pocet3 (car L)) (pocet3 (cdr L))))))
  34.  
  35. ;(print (pocet3 '(1 2 (3 4) 5 () 6)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement