Tail-Recursive Power Function in Scheme
问题 I am having trouble writing a tail-recursive power function in scheme. I want to write the function using a helper function. I know that I need to have a parameter to hold an accumulated value, but I am stuck after that. My code is as follows. (define (pow-tr a b) (define (pow-tr-h result) (if (= b 0) result pow-tr a (- b 1))(* result a)) pow-tr-h 1) I edited my code, and now it works. It is as follows: (define (pow-tr2 a b) (define (pow-tr2-h a b result) (if (= 0 b) result (pow-tr2-h a (- b