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 bulk recursive Scheme office renunciation with the aftercited description: a) ;; Usage: (renunciation n) Forn is integer, n> = 0 ;; Estimate: schedule of complete integers i, so that 0 <i <= n, in ascending appoint. For specimen, Scheme should repeat (renunciation 0) yield () and Scheme look (renunciation 5) must yield (1 2 3 45) b) ;; Usage: (introduce f u x) ;; For: f is a binary, ie fcomplete ; which takes two arguments ;; x is schedule (x1.. Xn) :, u is the estimate estimate : Estimate: (f (f (f (f u x1) x2) .) xN) For specimen, Scheme (introduce 3 (schedule 12)) should repeat 6 (3 +12)

    Write bulk recursive Scheme office renunciation with the aftercited description: a);;Usage: (renunciation n);: For: n is integer, n > = 0;: Estimate: schedule of complete integers i, so that;: 0

    Expert Tally

     

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