Advertisement
Guest User

Untitled

a guest
May 5th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 1.02 KB | None | 0 0
  1. (define (parzysta n)
  2.   (if (= n 0)
  3.       #t
  4.       (if (< n 0)
  5.           #f
  6.           (parzysta (- n 2)
  7.       ))))
  8.  
  9. (define (fib n)
  10.   (if (< n 3)
  11.       1
  12.       (+ (fib (- n 2)) (fib (- n 1)))))
  13.  
  14. (define (ileL n)
  15.   (if (number? n)
  16.       1
  17.       (+ (ileL (car n)) (ileL (cdr n)))))
  18.  
  19. (define (nalezy? n lst)
  20.   (if (null? lst)
  21.          #f
  22.          (if (equal? (car lst) n)
  23.              #t
  24.              (nalezy? n (cdr lst)))))
  25.  
  26. (define (polacz lst1 lst2)
  27.   (if (null? lst1)
  28.       lst2
  29.       (cons (car lst1) (polacz (cdr lst1) lst2))))
  30.  
  31. (define (podziel2 lst)
  32.   (if (null? lst)
  33.       lst
  34.       (cons (/ (car lst) 2) (podziel2 (cdr lst)))))
  35.  
  36. (define (silniaIT n)
  37.   (silniaITpom n 1))
  38. (define (silniaITpom n accumulator)
  39.   (if (= n 1)
  40.       accumulator
  41.       (silniaITpom (- n 1) (* accumulator n))))
  42.  
  43. (define (podziel2IT lst)
  44.   (podziel2ITpom lst '()))
  45. (define (podziel2ITpom lst accumulator)
  46.   (if (null? lst)
  47.       accumulator
  48.       (podziel2ITpom (cdr lst) (append accumulator (list (/ (car lst) 2))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement