X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fgacela_misc.scm;fp=src%2Fgacela_misc.scm;h=b75a44eb1cf91a4d1c1158db9c754a5c06687b0a;hb=042f93e750461b4d7235f702c973f0bd1effcae9;hp=c95abf5200e323d45465e89229d51e9fb7a29c9f;hpb=4fa4326c57c1022891fd0a7678f139119e997116;p=gacela.git diff --git a/src/gacela_misc.scm b/src/gacela_misc.scm index c95abf5..b75a44e 100644 --- a/src/gacela_misc.scm +++ b/src/gacela_misc.scm @@ -15,3 +15,8 @@ ;;; along with this program. If not, see . +(define (nearest-power-of-two n) + (define (power p n) + (cond ((> (* p 2) n) p) + (else (power (* p 2) n)))) + (power 1 n))