handling nil fix
This commit is contained in:
parent
ea09216550
commit
d72b758c59
4
ml.cpp
4
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<MlValue> 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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue