From d72b758c597e2ecf85632804e0322cb0196af6a4 Mon Sep 17 00:00:00 2001 From: vaclavt Date: Sat, 22 Jan 2022 23:03:13 +0100 Subject: [PATCH] handling nil fix --- ml.cpp | 4 ++-- ml_string.cpp | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ml.cpp b/ml.cpp index e87a4fb..343e326 100644 --- a/ml.cpp +++ b/ml.cpp @@ -197,7 +197,7 @@ bool MlValue::is_list() const { } bool MlValue::as_bool() const { - return type != NIL; + return !(type == NIL || (type == LIST && list.empty())); } long MlValue::as_int() const { @@ -949,7 +949,7 @@ MlValue if_then_else(std::vector args, MlEnvironment &env) { else if (args.size() == 3) return args[2].eval(env); - return MlValue(0l); + return MlValue::nil(); } // cond (SPECIAL FORM), in lisp it's macro, but we don't have support for macros yet diff --git a/ml_string.cpp b/ml_string.cpp index f8abab3..d4add77 100644 --- a/ml_string.cpp +++ b/ml_string.cpp @@ -30,7 +30,6 @@ bool regexp_search(const std::string &where, const std::string ®ex_str) { // for (size_t i = 0; i < match.size(); ++i) // std::cout << i << ": " << match[i] << '\n'; // std::cout << "Suffix: '" << match.suffix() << "\'\n\n"; - return true; } return false;