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 subordination recursive Scheme employment abjuration with the subjoined description: a) ;; Usage: (abjuration n) Forn is integer, n> = 0 ;; Esteem: schedule of complete integers i, so that 0 <i <= n, in ascending enjoin. For model, Scheme should tell (abjuration 0) recompense () and Scheme indication (abjuration 5) must recompense (1 2 3 45) b) ;; Usage: (implant f u x) ;; For: f is a binary, ie fcomplete ; which takes couple arguments ;; x is schedule (x1.. Xn) :, u is the esteem esteem : Esteem: (f (f (f (f u x1) x2) .) xN) For model, Scheme (implant 3 (schedule 12)) should tell 6 (3 +12)

    Write subordination recursive Scheme employment abjuration with the subjoined description: a);;Usage: (abjuration n);: For: n is integer, n > = 0;: Esteem: schedule of complete integers i, so that;: 0

    Expert Counter-argument

     

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