Advertisement
PomozMi

racket kurwa

Jun 11th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 1.60 KB | None | 0 0
  1. #lang racket
  2.  (require plot)
  3. (define(abs n)
  4.   (if
  5.    (> n 0)
  6.    n
  7.    (* n -1)))
  8.  
  9.  
  10. (define(silnia n)
  11. (if (= n 0)
  12.     1
  13. (* n (silnia ( - n 1)))))
  14.  
  15.  
  16. (define (parzyste lst)
  17.   (if
  18.    (null? lst)
  19.    '()
  20.    (if (= (modulo(car lst) 2) 0)
  21.        (cons (car lst)(parzyste (cdr lst)))
  22.              (parzyste(cdr lst)
  23.              )
  24.        )
  25.    )
  26.   )
  27.  
  28. (define (MYmember? x lst)
  29. (if (null? lst)
  30.     #f
  31.     (if (= (car lst) x)
  32.         ;;then
  33.         #t
  34.         ;;else
  35.         (MYmember? x (cdr lst))
  36.         );;cdr to tail ;;car to head
  37.     )
  38.   )
  39. (define (MYappend lst lst2)
  40. (if (null? lst)
  41.     lst2
  42.     (cons (car lst) (MYappend(cdr lst) lst2))
  43.     ))
  44.  
  45. ;;
  46.  
  47. (define (nazwa_funkcji f x)
  48.   (/ (- (f x) (f (- x 0.0001)))  0.0001 ))
  49.  
  50.  
  51. (define (deriv f) (lambda (x)
  52.   (/ (- (f x) (f (- x 0.0001)))  0.0001 )))
  53.  
  54.  
  55. ;;(plot (function (deriv cos) -3 30))
  56.  
  57. (define (qsort a)
  58.   (if (empty? a)
  59.     a
  60.     (let ([p (car a)])         ;;cdr to tail ;;car to head
  61.       (let ([tail (cdr a)])
  62.         (let ([lsr (filter (lambda (x) (< x p)) tail)]);pivot
  63.           (let ([grt (filter (lambda (x) (>= x p)) tail)]);pivot
  64.             (append (qsort lsr) (list p) (qsort grt))))))))
  65.  
  66. (define (wieksze n lst)
  67.     (if (null? lst)
  68.         '()
  69.         (if (> (car lst) n)
  70.             (cons (car lst) (wieksze n (cdr lst)))
  71.             (wieksze n (cdr lst))
  72.         );!if
  73.    );!if
  74. );!define
  75. (define (mniejsze n lst)
  76.     (if (null? lst)
  77.         '()
  78.         (if (<= (car lst) n)
  79.             (cons (car lst) (wieksze n (cdr lst)))
  80.             (wieksze n (cdr lst))
  81.         );!if
  82.    );!if
  83. );!define
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement