Advertisement
Teammasik

laba3_paradigmas

Apr 24th, 2023 (edited)
687
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.66 KB | None | 0 0
  1. ;https://www.cyberforum.ru/lisp/thread1670595.html for 2nd task
  2. ;1
  3. (defun summa (m n)
  4.     (cond ((> m n) 0)
  5.     ((evenp n) ( + n (summa m (- n 2))))
  6.     (t (summa m (- n 1)))))
  7. ;(print (summa 2 6 ))
  8.  
  9. ;2
  10. (defun counts (w)
  11.   (cond ((null w) 0)
  12.         ((symbolp w) 1)
  13.         ((+ (counts (car w)) (counts (cdr w))))))
  14.  
  15. ;(print(counts '(a (c c (d s s((s))) e)s)))
  16.  
  17. ;3
  18. (defun f(n)
  19.     (cond ((= n 0) 1)
  20.     ((= n 1) 2)
  21.     (t (-(* 2 (f (- n 1)))  (f(- n 2))))
  22.         ) )
  23.  
  24. ;(print (f 4))
  25.  
  26. ;4
  27. (defun create (a n)
  28.     (cond ((= n 0) nil)
  29.     (t(cons (cons a nil) (create a (- n 1))))
  30.         )
  31.             )
  32.    
  33.  
  34. ;(print(create 2 4))
  35.      
  36.  
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement