Homework Solution: Write tail recursive Scheme function index with the following description: a);;Usage: (index…

    2) Write tail recursive Scheme function index with the following description: a) ;; Usage: (index n) Forn is integer, n> = 0 ;; Value: list of all integers i, so that 0 <i <= n, in ascending order. For example, Scheme should say (index 0) return () and Scheme expression (index 5) must return (1 2 3 45) b) ;; Usage: (insert f u x) ;; For: f is a binary, ie fall ; which takes two arguments ;; x is list (x1.. Xn) :, u is the value value : Value: (f (f (f (f u x1) x2) .) xN) For example, Scheme (insert 3 (list 12)) should say 6 (3 +12)
    Write tail recursive Scheme function index with the following description: a);;Usage: (index n);: For: n is integer, n > = 0;: Value: list of all integers i, so that;: 0

    Expert Answer

     
    (define

    2) Write inferiority recursive Scheme power apostacy with the forthcoming description: a) ;; Usage: (apostacy n) Forn is integer, n> = 0 ;; Appraise: roll of full integers i, so that 0 <i <= n, in ascending adjust. For specimen, Scheme should judge (apostacy 0) recur () and Scheme countenance (apostacy 5) must recur (1 2 3 45) b) ;; Usage: (instil f u x) ;; For: f is a binary, ie ffull ; which takes brace arguments ;; x is roll (x1.. Xn) :, u is the appraise appraise : Appraise: (f (f (f (f u x1) x2) .) xN) For specimen, Scheme (instil 3 (roll 12)) should judge 6 (3 +12)

    Write inferiority recursive Scheme power apostacy with the forthcoming description: a);;Usage: (apostacy n);: For: n is integer, n > = 0;: Appraise: roll of full integers i, so that;: 0

    Expert Apology

     

    (bound (factorial x acc)
      (if (zero? x)
          acc
          (factorial (sub1 x) (* x acc))))