feat: 9.5.9
This commit is contained in:
parent
cb1753732b
commit
35f43a7909
1084 changed files with 558985 additions and 0 deletions
12
examples/power.ss
Normal file
12
examples/power.ss
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
;;; doubly recursive power (expt) function
|
||||
|
||||
;;; try using trace-lambda to see the nesting.
|
||||
|
||||
(define power
|
||||
(lambda (x n)
|
||||
(cond
|
||||
[(= n 0) 1]
|
||||
[(= n 1) x]
|
||||
[else
|
||||
(let ([q (quotient n 2)])
|
||||
(* (power x q) (power x (- n q))))])))
|
||||
Reference in a new issue