Skip to content

Commit

Permalink
Lipsticks
Browse files Browse the repository at this point in the history
Signed-off-by: yamacir-kit <[email protected]>
  • Loading branch information
yamacir-kit committed Oct 27, 2024
1 parent ab71190 commit 351c250
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 36 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,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.246_amd64.deb
sudo apt install build/meevax_0.5.247_amd64.deb
```

or
Expand Down Expand Up @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax

| Target Name | Description
|-------------|-------------
| `all` | Build shared-library `libmeevax.0.5.246.so` and executable `meevax`
| `all` | Build shared-library `libmeevax.0.5.247.so` and executable `meevax`
| `test` | Test executable `meevax`
| `package` | Generate debian package `meevax_0.5.246_amd64.deb`
| `package` | Generate debian package `meevax_0.5.247_amd64.deb`
| `install` | Copy files into `/usr/local` directly

## Usage
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.246
0.5.247
11 changes: 5 additions & 6 deletions include/meevax/kernel/homogeneous_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,14 @@ inline namespace kernel
return tag;
}

template <auto I = 0>
template <auto I = 0, typename Tuple = std::tuple<exact_integer, float, double>>
static auto input_cast(object const& x) -> T
{
using types = std::tuple<exact_integer, float, double>;

if constexpr (I < std::tuple_size_v<types>)
if constexpr (I < std::tuple_size_v<Tuple>)
{
using type = std::tuple_element_t<I, types>;
return x.is<type>() ? static_cast<T>(x.as<type>()) : input_cast<I + 1>(x);
using type_i = std::tuple_element_t<I, Tuple>;

return x.is<type_i>() ? static_cast<T>(x.as<type_i>()) : input_cast<I + 1>(x);
}
else
{
Expand Down
44 changes: 18 additions & 26 deletions src/kernel/number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,69 +302,61 @@ inline namespace kernel
}
}

template <auto I = 0, typename F>
template <auto I = 0, typename F, typename Tuple = std::tuple<exact_integer, ratio, float, double, complex>>
auto apply([[maybe_unused]] F f, object const& x) -> object
{
using Ts = std::tuple<exact_integer, ratio, float, double, complex>;

if constexpr (I < std::tuple_size_v<Ts>)
if constexpr (I < std::tuple_size_v<Tuple>)
{
using T = std::tuple_element_t<I, Ts>;
using type_i = std::tuple_element_t<I, Tuple>;

return x.is<T>() ? canonicalize(f(x.as<T>())) : apply<I + 1>(f, x);
return x.is<type_i>() ? canonicalize(f(x.as<type_i>())) : apply<I + 1>(f, x);
}
else
{
throw error(make<string>("not an number"));
}
}

template <auto I = 0, typename F>
template <auto I = 0, typename F, typename Tuple = combination<exact_integer, ratio, float, double, complex>>
auto apply([[maybe_unused]] F f, object const& x, object const& y) -> object
{
using Ts = combination<exact_integer, ratio, float, double, complex>;

if constexpr (I < std::tuple_size_v<Ts>)
if constexpr (I < std::tuple_size_v<Tuple>)
{
using T = std::tuple_element_t<0, std::tuple_element_t<I, Ts>>;
using U = std::tuple_element_t<1, std::tuple_element_t<I, Ts>>;
using type_i_0 = std::tuple_element_t<0, std::tuple_element_t<I, Tuple>>;
using type_i_1 = std::tuple_element_t<1, std::tuple_element_t<I, Tuple>>;

return x.is<T>() and y.is<U>() ? canonicalize(f(x.as<T>(), y.as<U>())) : apply<I + 1>(f, x, y);
return x.is<type_i_0>() and y.is<type_i_1>() ? canonicalize(f(x.as<type_i_0>(), y.as<type_i_1>())) : apply<I + 1>(f, x, y);
}
else
{
throw error(make<string>("not an number"));
}
}

template <auto I = 0, typename F>
template <auto I = 0, typename F, typename Tuple = std::tuple<exact_integer, ratio, float, double, complex>>
auto test([[maybe_unused]] F f, object const& x) -> bool
{
using Ts = std::tuple<exact_integer, ratio, float, double, complex>;

if constexpr (I < std::tuple_size_v<Ts>)
if constexpr (I < std::tuple_size_v<Tuple>)
{
using T = std::tuple_element_t<I, Ts>;
using type_i = std::tuple_element_t<I, Tuple>;

return x.is<T>() ? f(x.as<T>()) : test<I + 1>(f, x);
return x.is<type_i>() ? f(x.as<type_i>()) : test<I + 1>(f, x);
}
else
{
return false;
}
}

template <auto I = 0, typename F>
template <auto I = 0, typename F, typename Tuple = combination<exact_integer, ratio, float, double, complex>>
auto test([[maybe_unused]] F f, object const& x, object const& y) -> bool
{
using Ts = combination<exact_integer, ratio, float, double, complex>;

if constexpr (I < std::tuple_size_v<Ts>)
if constexpr (I < std::tuple_size_v<Tuple>)
{
using T = std::tuple_element_t<0, std::tuple_element_t<I, Ts>>;
using U = std::tuple_element_t<1, std::tuple_element_t<I, Ts>>;
using type_i_0 = std::tuple_element_t<0, std::tuple_element_t<I, Tuple>>;
using type_i_1 = std::tuple_element_t<1, std::tuple_element_t<I, Tuple>>;

return x.is<T>() and y.is<U>() ? f(x.as<T>(), y.as<U>()) : test<I + 1>(f, x, y);
return x.is<type_i_0>() and y.is<type_i_1>() ? f(x.as<type_i_0>(), y.as<type_i_1>()) : test<I + 1>(f, x, y);
}
else
{
Expand Down

0 comments on commit 351c250

Please sign in to comment.