(define (f1 x y) (+ x y) ) (define (f2 x) (lambda (y) (+ x y) ) ) (define (f3) (lambda (x y) (+ x y) ) ) (define (poredipoz) (lambda (x y) (cond ((> x y) 1) ((= x y) 0) (else -1) ) ) ) (define (poredineg) (lambda (x y) (cond ((> x y) -1) ((= x y) 0) (else 1) ) ) ) (define (poredi x y kriterijum) ((kriterijum) x y) ) ;(poredi 2 3 poredipoz) ;inkrementacija svakog elementa liste (define (listap1 L) (cond ((null? L) L) (else (cons (+ (car L) 1) (listap1 (cdr L)))) ) ) (define (listam2 L) (cond ((null? L) L) (else (cons (* (car L) 2) (listam2 (cdr L)))) ) ) (define (mymap L f) (cond ((null? L) L) (else (cons (f (car L)) (mymap (cdr L) f))) ) ) ;(mymap '(1 2 3 4) (lambda (x) (+ x 1))) ;(mymap '(1 2 3 4) (lambda (x) (* x 2))) (define (myfilter L f) (cond ((null? L) L) ((f (car L)) (cons (car L) (myfilter (cdr L) f))) (else (myfilter (cdr L) f)) ) ) (define (isn3 x) (cond ((= x 3) #f) (else #t) ) ) ;(myfilter '(1 2 3 4 5) isn3) (define (myfoldr L f e) (cond ((null? L) e) (else (f (car L) (myfoldr (cdr L) f e))) ) ) ;(myfold '(1 2 3 4 5) + 0) (define (myfoldl L f e) (cond ((null? L) e) (else (myfoldl (cdr L) f (f (car L) e))) ) ) ;duzina liste (define L1 '(1 2 3 4 5)) (define L2 '(2 3 12 4 6 7)) ;duzina liste preko folda (myfoldl L1 (lambda (x y) (+ 1 y)) 0) ;poslednji element liste (myfoldr L2 (lambda (x y) (cond ((null? y) x) (else y))) '()) ;check-range preko fold-a (define L3 '(11 22 66)) (myfoldl L3 (lambda(x y)(and (>= x 5)(<= x 95)y)) #t) ;compose-func (define (compose-func f g) (lambda (x) (f (g x)) ) ) (define L4 '((1 2) (3 4 5) (6))) (define (flatten L) (myfoldr L append '()) )