Skip to content

Commit

Permalink
Skrypt::PrintVarKnowns
Browse files Browse the repository at this point in the history
  • Loading branch information
ohhmm committed Dec 3, 2023
1 parent b13613c commit 785aa63
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ if(NOT GIT_EXECUTABLE)
find_package(Git)
endif()

find_package(Threads)

# Fetch some OpenMind
include(FetchContent)
FetchContent_Declare(openmind
Expand Down
31 changes: 22 additions & 9 deletions libskrypt/skrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,24 @@ void Skrypt::SetVarhost(decltype(varHost) host)
}
}

void Skrypt::PrintVarKnowns(const Variable& v)
{
std::cout << v << " =";
auto solutions = Solve(v);
for (auto& solution : solutions) {
std::cout << ' ' << solution;
}
std::cout << std::endl;
}

bool Skrypt::Add(std::string_view line) {
Valuable v(line, varHost);
v.CollectVaNames(vars);
bool ok = {};
try
{
if (v.IsVa()) {
std::cout << v << " =";
auto solutions = Solve(v.as<Variable>());
for (auto& solution : solutions) {
std::cout << ' ' << solution;
}
std::cout << std::endl;
PrintVarKnowns(v.as<Variable>());
ok = true;
}
else {
Expand All @@ -63,7 +68,7 @@ namespace {
return s;
}
}
const omnn::math::Valuable::va_names_t& skrypt::Skrypt::Load(std::istream& in)
const omnn::math::Valuable::va_names_t& Skrypt::Load(std::istream& in)
{
std::string line;
while (std::getline(in, line)) {
Expand All @@ -85,6 +90,12 @@ const omnn::math::Valuable::va_names_t& skrypt::Skrypt::Load(std::istream& in)
auto yes = false;
auto& total = Total();
auto questionless = Questionless(line);
if (questionless.empty()) {
for (auto& [name, var] : vars) {
PrintVarKnowns(var);
}
continue;
}
Valuable v(questionless, varHost);
auto lineVars = v.Vars();
if (total.IsSum()) {
Expand Down Expand Up @@ -116,7 +127,9 @@ const omnn::math::Valuable::va_names_t& skrypt::Skrypt::Load(std::istream& in)
IMPLEMENT
}
}
else {
else if(total == constants::zero) {

} else {
IMPLEMENT
}

Expand All @@ -133,7 +146,7 @@ const omnn::math::Valuable::va_names_t& skrypt::Skrypt::Load(std::istream& in)
return vars;
}

const omnn::math::Valuable::va_names_t& skrypt::Skrypt::Load(const boost::filesystem::path & path)
const omnn::math::Valuable::va_names_t& Skrypt::Load(const boost::filesystem::path & path)
{
std::cout << "Loading " << path << '\n' << std::endl;
boost::filesystem::ifstream stream(path);
Expand Down
4 changes: 3 additions & 1 deletion libskrypt/skrypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace skrypt {
{
using base = omnn::math::System;

BOOST_AUTO(varHost, ::omnn::math::VarHost::make<std::string>());
::omnn::math::VarHost::ptr varHost = ::omnn::math::VarHost::make<std::string>();

omnn::math::Valuable::va_names_t vars;
bool echo = {};
Expand All @@ -35,6 +35,8 @@ namespace skrypt {

bool Add(std::string_view);

void PrintVarKnowns(const omnn::math::Variable&);

/// <summary>
/// Loads .skrypt file and returns InitialVarNames for input
/// </summary>
Expand Down
7 changes: 6 additions & 1 deletion skrypt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@

exe(libskrypt)
exe(
libskrypt
Boost::filesystem
Boost::program_options
Boost::serialization
)

0 comments on commit 785aa63

Please sign in to comment.