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 continuation recursive Scheme duty abjuration with the aftercited description: a) ;; Usage: (abjuration n) Forn is integer, n> = 0 ;; Prize: catalogue of perfect integers i, so that 0 <i <= n, in ascending arrange. For copy, Scheme should judge (abjuration 0) repay () and Scheme indication (abjuration 5) must repay (1 2 3 45) b) ;; Usage: (infuse f u x) ;; For: f is a binary, ie fperfect ; which takes two arguments ;; x is catalogue (x1.. Xn) :, u is the prize prize : Prize: (f (f (f (f u x1) x2) .) xN) For copy, Scheme (infuse 3 (catalogue 12)) should judge 6 (3 +12)

    Write continuation recursive Scheme duty abjuration with the aftercited description: a);;Usage: (abjuration n);: For: n is integer, n > = 0;: Prize: catalogue of perfect integers i, so that;: 0

    Expert Defense

     

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