Skip to content

Commit ab9adc0

Browse files
authored
Merge pull request #411 from yamacir-kit/number
Number
2 parents c0db401 + f42ae14 commit ab9adc0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1725
-1545
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
1919
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2020
set(CMAKE_VERBOSE_MAKEFILE OFF)
2121

22-
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -Wno-parentheses -pipe")
22+
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -pipe")
2323
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")
2424
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
2525
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG")

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ sudo rm -rf /usr/local/share/meevax
105105

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

124124
```
125-
Meevax Lisp System, version 0.4.166
125+
Meevax Lisp System, version 0.4.232
126126
127127
Usage: meevax [OPTION...] [FILE...]
128128

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.166
1+
0.4.232

basis/r4rs.ss

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(define-library (scheme r4rs)
22
(import (meevax inexact)
3-
(only (meevax number) exact-integer? expt exact inexact ratio?)
3+
(only (meevax number) exact-integer? expt exact inexact ratio? ratio-numerator ratio-denominator)
44
(only (meevax port) get-ready? standard-input-port standard-output-port)
55
(only (meevax string) string-copy)
66
(only (meevax syntax) define-syntax)
@@ -71,12 +71,13 @@
7171
,body)))))))
7272

7373
(define (numerator x)
74-
(cond ((ratio? x) (car x))
74+
(cond ((ratio? x) (ratio-numerator x))
7575
((exact? x) x)
7676
(else (inexact (numerator (exact x))))))
7777

7878
(define (denominator x)
79-
(cond ((exact? x) (if (ratio? x) (cdr x) 1))
79+
(cond ((ratio? x) (ratio-denominator x))
80+
((exact? x) 1)
8081
((integer? x) 1.0)
8182
(else (inexact (denominator (exact x))))))
8283

basis/r7rs.ss

+20-19
Original file line numberDiff line numberDiff line change
@@ -433,27 +433,28 @@
433433
(define-library (scheme inexact)
434434
(import (only (meevax inexact) finite? infinite? nan?)
435435
(only (scheme r5rs) exp log sin cos tan asin acos atan sqrt))
436-
(export finite?
437-
infinite?
438-
nan?
439-
exp
440-
log
441-
sin
442-
cos
443-
tan
444-
asin
445-
acos
446-
atan
447-
sqrt))
436+
(export finite? infinite? nan? exp log sin cos tan asin acos atan sqrt))
448437

449438
(define-library (scheme complex)
450-
(export make-rectangular
451-
make-polar
452-
real-part
453-
imag-part
454-
angle
455-
)
456-
)
439+
(import (meevax complex)
440+
(scheme base)
441+
(scheme inexact))
442+
443+
(export make-rectangular make-polar real-part imag-part magnitude angle)
444+
445+
(begin (define (make-polar magnitude angle)
446+
(make-rectangular (* magnitude (cos angle))
447+
(* magnitude (sin angle))))
448+
449+
(define (magnitude z)
450+
(let ((re (real-part z))
451+
(im (imag-part z)))
452+
(sqrt (+ (* re re)
453+
(* im im)))))
454+
455+
(define (angle z)
456+
(atan (imag-part z)
457+
(real-part z)))))
457458

458459
(define-library (scheme cxr)
459460
(import (meevax pair))

configure/version.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ inline namespace kernel
6161
let static const features = list(
6262
make<symbol>("r4rs"),
6363
make<symbol>("exact-closed"),
64-
// make<symbol>("exact-complex"),
64+
make<symbol>("exact-complex"),
6565
make<symbol>("ieee-float"),
6666
// make<symbol>("full-unicode"),
6767
make<symbol>("ratios"),

include/meevax/functional/arithmetic_operation.hpp

-58
This file was deleted.

include/meevax/functional/combinator.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ namespace meevax
2323
{
2424
inline namespace functional
2525
{
26-
auto i = [](auto&& x) constexpr
26+
inline auto i = [](auto&& x) constexpr
2727
{
2828
return std::forward<decltype(x)>(x);
2929
};
3030

31-
auto y = [](auto&& f) constexpr -> decltype(auto)
31+
inline auto y = [](auto&& f) constexpr -> decltype(auto)
3232
{
3333
return [&](auto&&... xs) -> decltype(auto)
3434
{
3535
return f(f, std::forward<decltype(xs)>(xs)...);
3636
};
3737
};
3838

39-
auto z = [](auto&& f) constexpr -> decltype(auto)
39+
inline auto z = [](auto&& f) constexpr -> decltype(auto)
4040
{
4141
return curry(std::forward<decltype(f)>(f))
4242
(std::forward<decltype(f)>(f));

include/meevax/functional/compose.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace meevax
2424
{
2525
inline namespace functional
2626
{
27-
auto compose = [](auto&& f, auto&& g) constexpr
27+
inline auto compose = [](auto&& f, auto&& g) constexpr
2828
{
2929
return [fs = std::forward_as_tuple(f, g)](auto&&... xs) constexpr -> decltype(auto)
3030
{

include/meevax/iostream/concatenate.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace meevax
2323
{
2424
inline namespace iostream
2525
{
26-
auto concatenate = [](auto&&... xs)
26+
inline auto concatenate = [](auto&&... xs)
2727
{
2828
std::stringstream ss;
2929
(ss << ... << xs);

include/meevax/iostream/escape_sequence.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ inline namespace iostream
3333

3434
std::tuple<
3535
typename std::conditional<
36-
not std::is_reference<Ts>::value or std::is_scalar<typename std::remove_reference<Ts>::type>::value,
37-
typename std::decay<Ts>::type,
38-
std::reference_wrapper<typename std::remove_reference<Ts>::type>
36+
not std::is_reference_v<Ts> or std::is_scalar_v<std::remove_reference_t<Ts>>,
37+
std::decay_t<Ts>,
38+
std::reference_wrapper<std::remove_reference_t<Ts>>
3939
>::type...
4040
> references;
4141

@@ -70,7 +70,7 @@ inline namespace iostream
7070
escape_sequence(T&&, Ts&&...) -> escape_sequence<Ts...>;
7171

7272
#define DEFINE(COMMAND, NAME) \
73-
auto NAME = [](auto&&... xs) \
73+
inline auto NAME = [](auto&&... xs) \
7474
{ \
7575
return escape_sequence(COMMAND, std::forward<decltype(xs)>(xs)...); \
7676
}

include/meevax/iostream/is_console.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace meevax
2525
{
2626
inline namespace iostream
2727
{
28-
auto is_console = [](std::ostream & os)
28+
inline auto is_console = [](std::ostream & os)
2929
{
3030
if (os.rdbuf() == std::cout.rdbuf())
3131
{

include/meevax/iostream/lexical_cast.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ inline namespace iostream
3030
{
3131
if (std::stringstream ss; (ss << ... << xs))
3232
{
33-
if constexpr (std::is_same<typename std::decay<To>::type, std::string>::value)
33+
if constexpr (std::is_same_v<std::decay_t<To>, std::string>)
3434
{
3535
return ss.str();
3636
}

include/meevax/kernel/character.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ inline namespace kernel
5959
return codepoint;
6060
}
6161

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

6565
auto operator <<(std::ostream &, character const&) -> std::ostream &; // write

include/meevax/kernel/complex.hpp

+8-46
Original file line numberDiff line numberDiff line change
@@ -17,67 +17,29 @@
1717
#ifndef INCLUDED_MEEVAX_KERNEL_COMPLEX_HPP
1818
#define INCLUDED_MEEVAX_KERNEL_COMPLEX_HPP
1919

20+
#include <complex>
21+
#include <regex>
22+
2023
#include <meevax/kernel/ghost.hpp>
2124
#include <meevax/kernel/pair.hpp>
2225

2326
namespace meevax
2427
{
2528
inline namespace kernel
2629
{
27-
struct complex : public number
28-
, public virtual pair
30+
struct complex : public virtual pair
2931
{
3032
using pair::pair;
3133

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

34-
auto real() noexcept -> reference;
36+
auto canonicalize() const -> value_type;
3537

3638
auto imag() const noexcept -> const_reference;
3739

38-
auto imag() noexcept -> reference;
39-
40-
#define DEFINE(NAME) \
41-
auto NAME() const -> value_type override \
42-
{ \
43-
return unspecified; \
44-
} \
45-
static_assert(true)
46-
47-
DEFINE(exact); DEFINE(inexact);
48-
49-
DEFINE(sin); DEFINE(asin); DEFINE(sinh); DEFINE(asinh); DEFINE(exp);
50-
DEFINE(cos); DEFINE(acos); DEFINE(cosh); DEFINE(acosh); DEFINE(log);
51-
DEFINE(tan); DEFINE(atan); DEFINE(tanh); DEFINE(atanh); DEFINE(sqrt);
52-
53-
DEFINE(floor); DEFINE(ceil); DEFINE(trunc); DEFINE(round);
54-
55-
#undef DEFINE
56-
57-
#define DEFINE(NAME) \
58-
auto NAME(const_reference) const -> value_type override \
59-
{ \
60-
return unspecified; \
61-
} \
62-
static_assert(true)
63-
64-
DEFINE(atan2);
65-
DEFINE(pow);
66-
67-
#undef DEFINE
68-
69-
auto operator + (const_reference) const -> value_type override { return unspecified; }
70-
auto operator - (const_reference) const -> value_type override { return unspecified; }
71-
auto operator * (const_reference) const -> value_type override { return unspecified; }
72-
auto operator / (const_reference) const -> value_type override { return unspecified; }
73-
auto operator % (const_reference) const -> value_type override { return unspecified; }
40+
auto real() const noexcept -> const_reference;
7441

75-
auto operator ==(const_reference) const -> bool override { return false; };
76-
auto operator !=(const_reference) const -> bool override { return false; };
77-
auto operator < (const_reference) const -> bool override { return false; };
78-
auto operator <=(const_reference) const -> bool override { return false; };
79-
auto operator > (const_reference) const -> bool override { return false; };
80-
auto operator >=(const_reference) const -> bool override { return false; };
42+
explicit operator std::complex<double>();
8143
};
8244

8345
auto operator <<(std::ostream &, complex const&) -> std::ostream &;

include/meevax/kernel/constant.hpp

-30
This file was deleted.

include/meevax/kernel/environment.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ inline namespace kernel
4646

4747
explicit environment(environment const&) = default;
4848

49-
template <typename... Ts, REQUIRES(std::is_convertible<Ts, external_representation>...)>
49+
template <typename... Ts, REQUIRES(std::is_convertible<Ts, std::string>...)>
5050
explicit environment(Ts&&... xs)
5151
{
5252
(import(xs), ...);
@@ -88,9 +88,9 @@ inline namespace kernel
8888

8989
auto import_(const_reference) -> void;
9090

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

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

9595
auto resolve(const_reference) -> value_type;
9696

0 commit comments

Comments
 (0)