diff --git a/embddr/common.scm b/embddr/common.scm index 48eacce..79c5414 100644 --- a/embddr/common.scm +++ b/embddr/common.scm @@ -5,7 +5,7 @@ (import (srfi srfi-1) (srfi srfi-60)) - (export log2 clog2 + (export log2 clog2 round-to one? power-of-two? curry curry-r transpose @@ -36,6 +36,11 @@ ;;; Check for (x == 1) (define (one? x) (= x 1)) +;;; Round to the 'n' decimal place +(define (round-to n num) + (let ((k (expt 10 n))) + (/ (round (* num k)) k))) + ;;; Currying ;;; Example: ((curry-r f 1) 2 3) -> (f 1 2 3) (define (curry f . args)