Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #lang racket
- (require plot)
- (define(abs n)
- (if
- (> n 0)
- n
- (* n -1)))
- (define(silnia n)
- (if (= n 0)
- 1
- (* n (silnia ( - n 1)))))
- (define (parzyste lst)
- (if
- (null? lst)
- '()
- (if (= (modulo(car lst) 2) 0)
- (cons (car lst)(parzyste (cdr lst)))
- (parzyste(cdr lst)
- )
- )
- )
- )
- (define (MYmember? x lst)
- (if (null? lst)
- #f
- (if (= (car lst) x)
- ;;then
- #t
- ;;else
- (MYmember? x (cdr lst))
- );;cdr to tail ;;car to head
- )
- )
- (define (MYappend lst lst2)
- (if (null? lst)
- lst2
- (cons (car lst) (MYappend(cdr lst) lst2))
- ))
- ;;
- (define (nazwa_funkcji f x)
- (/ (- (f x) (f (- x 0.0001))) 0.0001 ))
- (define (deriv f) (lambda (x)
- (/ (- (f x) (f (- x 0.0001))) 0.0001 )))
- ;;(plot (function (deriv cos) -3 30))
- (define (qsort a)
- (if (empty? a)
- a
- (let ([p (car a)]) ;;cdr to tail ;;car to head
- (let ([tail (cdr a)])
- (let ([lsr (filter (lambda (x) (< x p)) tail)]);pivot
- (let ([grt (filter (lambda (x) (>= x p)) tail)]);pivot
- (append (qsort lsr) (list p) (qsort grt))))))))
- (define (wieksze n lst)
- (if (null? lst)
- '()
- (if (> (car lst) n)
- (cons (car lst) (wieksze n (cdr lst)))
- (wieksze n (cdr lst))
- );!if
- );!if
- );!define
- (define (mniejsze n lst)
- (if (null? lst)
- '()
- (if (<= (car lst) n)
- (cons (car lst) (wieksze n (cdr lst)))
- (wieksze n (cdr lst))
- );!if
- );!if
- );!define
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement