diff --git a/README.md b/README.md index 2deadfa01..f1c405c0e 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ Procedures for each standard are provided by the following R7RS-style libraries: cmake -B build -DCMAKE_BUILD_TYPE=Release cd build make package -sudo apt install build/meevax_0.5.5_amd64.deb +sudo apt install build/meevax_0.5.6_amd64.deb ``` or @@ -131,9 +131,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.5.so` and executable `meevax` +| `all` | Build shared-library `libmeevax.0.5.6.so` and executable `meevax` | `test` | Test executable `meevax` -| `package` | Generate debian package `meevax_0.5.5_amd64.deb` +| `package` | Generate debian package `meevax_0.5.6_amd64.deb` | `install` | Copy files into `/usr/local` directly ## Usage diff --git a/VERSION b/VERSION index d1d899fa3..b49b25336 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.5 +0.5.6 diff --git a/basis/r4rs.ss b/basis/r4rs.ss index 0d155260e..e0d601a0b 100644 --- a/basis/r4rs.ss +++ b/basis/r4rs.ss @@ -42,10 +42,33 @@ (only (meevax continuation) call-with-current-continuation) (prefix (only (meevax environment) load) %) (only (meevax function) procedure?) - (meevax inexact) + (only (meevax inexact) exp log sqrt sin cos tan asin acos atan) (meevax list) (only (meevax macro-transformer) er-macro-transformer identifier?) - (meevax number) + (only (meevax number) + number? + complex? + real? + rational? + integer? + = < > <= >= + + * - / + abs + % ; deprecated + ratio-numerator ; deprecated + ratio-denominator ; deprecated + floor ceiling truncate round + expt + exact inexact + string->number + + ; to be removed + exact-integer? ; r7rs + imaginary? + ratio? + single-float? + double-float? + ) (meevax pair) (meevax port) (prefix (meevax read) %) diff --git a/include/meevax/kernel/number.hpp b/include/meevax/kernel/number.hpp index 6e69f4a29..ed02016c8 100644 --- a/include/meevax/kernel/number.hpp +++ b/include/meevax/kernel/number.hpp @@ -363,6 +363,8 @@ inline namespace number auto is_integer(object const&) -> bool; + auto is_exact(object const&) -> bool; + auto is_finite(object const&) -> bool; auto is_infinite(object const&) -> bool; diff --git a/src/kernel/boot.cpp b/src/kernel/boot.cpp index 40df6f89f..5cc111d01 100644 --- a/src/kernel/boot.cpp +++ b/src/kernel/boot.cpp @@ -540,26 +540,35 @@ inline namespace kernel return is_integer(xs[0]); }); + library.define("exact?", [](let const& xs) + { + return is_exact(xs[0]); + }); + library.define("exact-integer?", [](let const& xs) { return xs[0].is(); }); + // TODO REMOVE library.define("imaginary?", [](let const& xs) { return xs[0].is(); }); + // TODO REMOVE library.define("ratio?", [](let const& xs) { return xs[0].is(); }); + // TODO REMOVE library.define("single-float?", [](let const& xs) { return xs[0].is(); }); + // TODO REMOVE library.define("double-float?", [](let const& xs) { return xs[0].is(); @@ -624,6 +633,7 @@ inline namespace kernel } }); + // TODO RENAME library.define("%", [](let const& xs) { return xs[0] % xs[1]; @@ -634,6 +644,10 @@ inline namespace kernel return abs(xs[0]); }); + // TODO QUOTIENT + // TODO REMAINDER + // TODO MODULO + library.define("ratio-numerator", [](let const& xs) { return make(xs[0].as().numerator()); diff --git a/src/kernel/number.cpp b/src/kernel/number.cpp index a7930373c..4f24a7d8f 100644 --- a/src/kernel/number.cpp +++ b/src/kernel/number.cpp @@ -659,6 +659,25 @@ inline namespace number return test(f, x); } + auto is_exact(object const& x) -> bool + { + auto f = [](auto const& x) + { + using T = std::decay_t; + + if constexpr (std::is_same_v) + { + return is_exact(x.real()) and is_exact(x.imag()); + } + else + { + return std::is_same_v or std::is_same_v; + } + }; + + return test(f, x); + } + auto is_finite(object const& x) -> bool { return not is_infinite(x);