Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;https://www.cyberforum.ru/lisp/thread1670595.html for 2nd task
- ;1
- (defun summa (m n)
- (cond ((> m n) 0)
- ((evenp n) ( + n (summa m (- n 2))))
- (t (summa m (- n 1)))))
- ;(print (summa 2 6 ))
- ;2
- (defun counts (w)
- (cond ((null w) 0)
- ((symbolp w) 1)
- ((+ (counts (car w)) (counts (cdr w))))))
- ;(print(counts '(a (c c (d s s((s))) e)s)))
- ;3
- (defun f(n)
- (cond ((= n 0) 1)
- ((= n 1) 2)
- (t (-(* 2 (f (- n 1))) (f(- n 2))))
- ) )
- ;(print (f 4))
- ;4
- (defun create (a n)
- (cond ((= n 0) nil)
- (t(cons (cons a nil) (create a (- n 1))))
- )
- )
- ;(print(create 2 4))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement