Skip to content

Commit

Permalink
Merge pull request #411 from yamacir-kit/number
Browse files Browse the repository at this point in the history
Number
  • Loading branch information
yamacir-kit authored Sep 14, 2022
2 parents c0db401 + f42ae14 commit ab9adc0
Show file tree
Hide file tree
Showing 64 changed files with 1,725 additions and 1,545 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_VERBOSE_MAKEFILE OFF)

set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -Wno-parentheses -pipe")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -pipe")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG")
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ sudo rm -rf /usr/local/share/meevax

| Target Name | Description
|:-------------------|:--
| `all` (default) | Build shared-library `libmeevax.0.4.166.so` and executable `meevax`.
| `all` (default) | Build shared-library `libmeevax.0.4.232.so` and executable `meevax`.
| `test` | Test executable `meevax`.
| `package` | Generate debian package `meevax_0.4.166_amd64.deb`.
| `package` | Generate debian package `meevax_0.4.232_amd64.deb`.
| `install` | Copy files into `/usr/local` __(1)__.
| `install.deb` | `all` + `package` + `sudo apt install <meevax>.deb`
| `safe-install.deb` | `all` + `test` + `package` + `sudo apt install <meevax>.deb`
Expand All @@ -122,7 +122,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's
## Usage

```
Meevax Lisp System, version 0.4.166
Meevax Lisp System, version 0.4.232
Usage: meevax [OPTION...] [FILE...]
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.166
0.4.232
7 changes: 4 additions & 3 deletions basis/r4rs.ss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(define-library (scheme r4rs)
(import (meevax inexact)
(only (meevax number) exact-integer? expt exact inexact ratio?)
(only (meevax number) exact-integer? expt exact inexact ratio? ratio-numerator ratio-denominator)
(only (meevax port) get-ready? standard-input-port standard-output-port)
(only (meevax string) string-copy)
(only (meevax syntax) define-syntax)
Expand Down Expand Up @@ -71,12 +71,13 @@
,body)))))))

(define (numerator x)
(cond ((ratio? x) (car x))
(cond ((ratio? x) (ratio-numerator x))
((exact? x) x)
(else (inexact (numerator (exact x))))))

(define (denominator x)
(cond ((exact? x) (if (ratio? x) (cdr x) 1))
(cond ((ratio? x) (ratio-denominator x))
((exact? x) 1)
((integer? x) 1.0)
(else (inexact (denominator (exact x))))))

Expand Down
39 changes: 20 additions & 19 deletions basis/r7rs.ss
Original file line number Diff line number Diff line change
Expand Up @@ -433,27 +433,28 @@
(define-library (scheme inexact)
(import (only (meevax inexact) finite? infinite? nan?)
(only (scheme r5rs) exp log sin cos tan asin acos atan sqrt))
(export finite?
infinite?
nan?
exp
log
sin
cos
tan
asin
acos
atan
sqrt))
(export finite? infinite? nan? exp log sin cos tan asin acos atan sqrt))

(define-library (scheme complex)
(export make-rectangular
make-polar
real-part
imag-part
angle
)
)
(import (meevax complex)
(scheme base)
(scheme inexact))

(export make-rectangular make-polar real-part imag-part magnitude angle)

(begin (define (make-polar magnitude angle)
(make-rectangular (* magnitude (cos angle))
(* magnitude (sin angle))))

(define (magnitude z)
(let ((re (real-part z))
(im (imag-part z)))
(sqrt (+ (* re re)
(* im im)))))

(define (angle z)
(atan (imag-part z)
(real-part z)))))

(define-library (scheme cxr)
(import (meevax pair))
Expand Down
2 changes: 1 addition & 1 deletion configure/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ inline namespace kernel
let static const features = list(
make<symbol>("r4rs"),
make<symbol>("exact-closed"),
// make<symbol>("exact-complex"),
make<symbol>("exact-complex"),
make<symbol>("ieee-float"),
// make<symbol>("full-unicode"),
make<symbol>("ratios"),
Expand Down
58 changes: 0 additions & 58 deletions include/meevax/functional/arithmetic_operation.hpp

This file was deleted.

6 changes: 3 additions & 3 deletions include/meevax/functional/combinator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ namespace meevax
{
inline namespace functional
{
auto i = [](auto&& x) constexpr
inline auto i = [](auto&& x) constexpr
{
return std::forward<decltype(x)>(x);
};

auto y = [](auto&& f) constexpr -> decltype(auto)
inline auto y = [](auto&& f) constexpr -> decltype(auto)
{
return [&](auto&&... xs) -> decltype(auto)
{
return f(f, std::forward<decltype(xs)>(xs)...);
};
};

auto z = [](auto&& f) constexpr -> decltype(auto)
inline auto z = [](auto&& f) constexpr -> decltype(auto)
{
return curry(std::forward<decltype(f)>(f))
(std::forward<decltype(f)>(f));
Expand Down
2 changes: 1 addition & 1 deletion include/meevax/functional/compose.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace meevax
{
inline namespace functional
{
auto compose = [](auto&& f, auto&& g) constexpr
inline auto compose = [](auto&& f, auto&& g) constexpr
{
return [fs = std::forward_as_tuple(f, g)](auto&&... xs) constexpr -> decltype(auto)
{
Expand Down
2 changes: 1 addition & 1 deletion include/meevax/iostream/concatenate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace meevax
{
inline namespace iostream
{
auto concatenate = [](auto&&... xs)
inline auto concatenate = [](auto&&... xs)
{
std::stringstream ss;
(ss << ... << xs);
Expand Down
8 changes: 4 additions & 4 deletions include/meevax/iostream/escape_sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ inline namespace iostream

std::tuple<
typename std::conditional<
not std::is_reference<Ts>::value or std::is_scalar<typename std::remove_reference<Ts>::type>::value,
typename std::decay<Ts>::type,
std::reference_wrapper<typename std::remove_reference<Ts>::type>
not std::is_reference_v<Ts> or std::is_scalar_v<std::remove_reference_t<Ts>>,
std::decay_t<Ts>,
std::reference_wrapper<std::remove_reference_t<Ts>>
>::type...
> references;

Expand Down Expand Up @@ -70,7 +70,7 @@ inline namespace iostream
escape_sequence(T&&, Ts&&...) -> escape_sequence<Ts...>;

#define DEFINE(COMMAND, NAME) \
auto NAME = [](auto&&... xs) \
inline auto NAME = [](auto&&... xs) \
{ \
return escape_sequence(COMMAND, std::forward<decltype(xs)>(xs)...); \
}
Expand Down
2 changes: 1 addition & 1 deletion include/meevax/iostream/is_console.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace meevax
{
inline namespace iostream
{
auto is_console = [](std::ostream & os)
inline auto is_console = [](std::ostream & os)
{
if (os.rdbuf() == std::cout.rdbuf())
{
Expand Down
2 changes: 1 addition & 1 deletion include/meevax/iostream/lexical_cast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ inline namespace iostream
{
if (std::stringstream ss; (ss << ... << xs))
{
if constexpr (std::is_same<typename std::decay<To>::type, std::string>::value)
if constexpr (std::is_same_v<std::decay_t<To>, std::string>)
{
return ss.str();
}
Expand Down
2 changes: 1 addition & 1 deletion include/meevax/kernel/character.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ inline namespace kernel
return codepoint;
}

explicit operator external_representation() const; // write-char (for display)
explicit operator std::string() const; // write-char (for display)
};

auto operator <<(std::ostream &, character const&) -> std::ostream &; // write
Expand Down
54 changes: 8 additions & 46 deletions include/meevax/kernel/complex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,67 +17,29 @@
#ifndef INCLUDED_MEEVAX_KERNEL_COMPLEX_HPP
#define INCLUDED_MEEVAX_KERNEL_COMPLEX_HPP

#include <complex>
#include <regex>

#include <meevax/kernel/ghost.hpp>
#include <meevax/kernel/pair.hpp>

namespace meevax
{
inline namespace kernel
{
struct complex : public number
, public virtual pair
struct complex : public virtual pair
{
using pair::pair;

auto real() const noexcept -> const_reference;
explicit complex(std::string const&, int = 10);

auto real() noexcept -> reference;
auto canonicalize() const -> value_type;

auto imag() const noexcept -> const_reference;

auto imag() noexcept -> reference;

#define DEFINE(NAME) \
auto NAME() const -> value_type override \
{ \
return unspecified; \
} \
static_assert(true)

DEFINE(exact); DEFINE(inexact);

DEFINE(sin); DEFINE(asin); DEFINE(sinh); DEFINE(asinh); DEFINE(exp);
DEFINE(cos); DEFINE(acos); DEFINE(cosh); DEFINE(acosh); DEFINE(log);
DEFINE(tan); DEFINE(atan); DEFINE(tanh); DEFINE(atanh); DEFINE(sqrt);

DEFINE(floor); DEFINE(ceil); DEFINE(trunc); DEFINE(round);

#undef DEFINE

#define DEFINE(NAME) \
auto NAME(const_reference) const -> value_type override \
{ \
return unspecified; \
} \
static_assert(true)

DEFINE(atan2);
DEFINE(pow);

#undef DEFINE

auto operator + (const_reference) const -> value_type override { return unspecified; }
auto operator - (const_reference) const -> value_type override { return unspecified; }
auto operator * (const_reference) const -> value_type override { return unspecified; }
auto operator / (const_reference) const -> value_type override { return unspecified; }
auto operator % (const_reference) const -> value_type override { return unspecified; }
auto real() const noexcept -> const_reference;

auto operator ==(const_reference) const -> bool override { return false; };
auto operator !=(const_reference) const -> bool override { return false; };
auto operator < (const_reference) const -> bool override { return false; };
auto operator <=(const_reference) const -> bool override { return false; };
auto operator > (const_reference) const -> bool override { return false; };
auto operator >=(const_reference) const -> bool override { return false; };
explicit operator std::complex<double>();
};

auto operator <<(std::ostream &, complex const&) -> std::ostream &;
Expand Down
30 changes: 0 additions & 30 deletions include/meevax/kernel/constant.hpp

This file was deleted.

6 changes: 3 additions & 3 deletions include/meevax/kernel/environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ inline namespace kernel

explicit environment(environment const&) = default;

template <typename... Ts, REQUIRES(std::is_convertible<Ts, external_representation>...)>
template <typename... Ts, REQUIRES(std::is_convertible<Ts, std::string>...)>
explicit environment(Ts&&... xs)
{
(import(xs), ...);
Expand Down Expand Up @@ -88,9 +88,9 @@ inline namespace kernel

auto import_(const_reference) -> void;

auto import_(external_representation const&) -> void;
auto import_(std::string const&) -> void;

auto load(external_representation const&) -> value_type;
auto load(std::string const&) -> value_type;

auto resolve(const_reference) -> value_type;

Expand Down
Loading

0 comments on commit ab9adc0

Please sign in to comment.