Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #lang racket
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (define (find-max f a b);s max-from-a-with-b obhojdame za vsi4ki ot a do b. a tuka obhojdame za vsi4ki b-ta
- (define (iter a b max)
- (if (< b (+ a 1))
- max
- (if (> max (max-from-a-with-b f a b max))
- (iter a (- b 1) max)
- (iter a (- b 1) (max-from-a-with-b f a b max))
- )
- )
- )
- (iter a b (from-a-to-b f a b))
- )
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (define (max-from-a-with-b f a b max);obhojda i da e ot a do b-1 a j ti e b
- (if (> a (- b 1))
- max;kato obhodim vsi4ki vrushtame max
- (if(> max (from-a-to-b f a b))
- (max-from-a-with-b f (+ a 1) b max);iterirame ostanalite case-ove s max poneje max is bigger
- (max-from-a-with-b f (+ a 1) b (from-a-to-b f a b));iterirame ostanalite kato smenqme maxa s po-golqmoto
- )
- )
- )
- (define (from-a-to-b f a b)
- (define (helper f a b);tuka dori ne ti trqbva helper if u think about it no taka e po-ponqtno
- (if (= a b)
- a;
- (f a (helper f (+ a 1) b))
- )
- )
- (helper f a b)
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement