CS代考程序代写 scheme (define (multiplyBy x)

(define (multiplyBy x)
(lambda(y) (* x y)))

(define double (multiplyBy 2))
(define triple (multiplyBy 3))

(double 2) ;=> 4
(triple 5) ;=> 15

;(define triple (multiplyBy 3))
;(lambda(y) (* 3 y))

;(triple 5)
;(* 3 5)
;15

(((lambda(a) (lambda(b c)(if (> (- b c) a) “pizza” “french fries”))) 5) 11 5)

(define (boxcar h a b)
(lambda(x)(if (and (>= x a)(<= x b)) h 0))) (define box1 (boxcar 10 3 7)) (box1 5) ;(#%require plot) ;borrowed from racket (not scheme) ;(plot (function box1 0 20)) ;(plot (function (boxcar 25 5 10) 0 20)) (define (foo f) (lambda(x) (lambda(y) (lambda(z) (f x y z))))) (foo +) ((foo +) 1) (((foo +) 1) 2) ((((foo +) 1) 2) 3) (define (bar x y z)(- (* x y)z)) (foo bar) ((((foo bar) 3)4)5) (define (func a) ((lambda(b) (lambda(c d)(-(* b c)d))) (+ a 3))) (func 1) (define closure (func 1)) (closure 2 3) ((func 1) 2 3)