[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-177-gcf9d4
From: |
Andy Wingo |
Subject: |
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-177-gcf9d4a8 |
Date: |
Mon, 11 Apr 2011 15:57:57 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".
http://git.savannah.gnu.org/cgit/guile.git/commit/?id=cf9d4a82146556ff45d40d6eec8579082287900e
The branch, stable-2.0 has been updated
via cf9d4a82146556ff45d40d6eec8579082287900e (commit)
from 62ef23cbb828accf1f5b9622ff17775aa539d354 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit cf9d4a82146556ff45d40d6eec8579082287900e
Author: Ian Price <address@hidden>
Date: Wed Apr 6 01:53:38 2011 +0100
Added optional second arg to R6RS log function
* module/rnrs/base.scm (log): now takes a base argument, using the
change of base formula for logs.
* test-suite/tests/r6rs-base.test ("log (2nd arg)"): Add test cases.
-----------------------------------------------------------------------
Summary of changes:
module/rnrs/base.scm | 9 +++++++++
test-suite/tests/r6rs-base.test | 16 ++++++++++++++++
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/module/rnrs/base.scm b/module/rnrs/base.scm
index b9dddab..b867929 100644
--- a/module/rnrs/base.scm
+++ b/module/rnrs/base.scm
@@ -74,6 +74,7 @@
syntax-rules identifier-syntax)
(import (rename (except (guile) error raise)
+ (log log-internal)
(euclidean-quotient div)
(euclidean-remainder mod)
(euclidean/ div-and-mod)
@@ -85,6 +86,14 @@
(inexact->exact exact))
(srfi srfi-11))
+ (define log
+ (case-lambda
+ ((n)
+ (log-internal n))
+ ((n base)
+ (/ (log n)
+ (log base)))))
+
(define (boolean=? . bools)
(define (boolean=?-internal lst last)
(or (null? lst)
diff --git a/test-suite/tests/r6rs-base.test b/test-suite/tests/r6rs-base.test
index 1509b04..dfddf7c 100644
--- a/test-suite/tests/r6rs-base.test
+++ b/test-suite/tests/r6rs-base.test
@@ -21,6 +21,22 @@
:use-module ((rnrs base) :version (6))
:use-module (test-suite lib))
+
+;; numbers are considered =? if their difference is less than a set
+;; tolerance
+(define (=? alpha beta)
+ (< (abs (- alpha beta)) 1e-10))
+
+(with-test-prefix "log (2nd arg)"
+ (pass-if "log positive-base" (=? (log 8 2) 3))
+ (pass-if "log negative-base" (=? (real-part (log 256 -4))
+ 0.6519359443))
+ (pass-if "log base-one" (= (log 10 1) +inf.0))
+ (pass-if "log base-zero"
+ (catch #t
+ (lambda () (log 10 0) #f)
+ (lambda args #t))))
+
(with-test-prefix "boolean=?"
(pass-if "boolean=? null" (boolean=?))
(pass-if "boolean=? unary" (boolean=? #f))
hooks/post-receive
--
GNU Guile
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-177-gcf9d4a8,
Andy Wingo <=