MlValue::is_string added
This commit is contained in:
parent
fb25a7ea40
commit
08131d3e4e
6
ml.cpp
6
ml.cpp
|
|
@ -168,7 +168,7 @@ std::vector<std::string> MlValue::get_used_atoms() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is this a builtin function?
|
// Is this a builtin function?
|
||||||
bool MlValue::is_builtin() {
|
bool MlValue::is_builtin() const {
|
||||||
return type == BUILTIN;
|
return type == BUILTIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,6 +176,10 @@ bool MlValue::is_number() const {
|
||||||
return type == INT || type == FLOAT;
|
return type == INT || type == FLOAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MlValue::is_string() const {
|
||||||
|
return type == STRING;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the "truthy" boolean value of this value.
|
// Get the "truthy" boolean value of this value.
|
||||||
bool MlValue::as_bool() const {
|
bool MlValue::as_bool() const {
|
||||||
return type != NIL && *this != MlValue(0l); // TODO remove 0 as false
|
return type != NIL && *this != MlValue(0l); // TODO remove 0 as false
|
||||||
|
|
|
||||||
7
ml.h
7
ml.h
|
|
@ -136,17 +136,18 @@ public:
|
||||||
|
|
||||||
std::vector<std::string> get_used_atoms();
|
std::vector<std::string> get_used_atoms();
|
||||||
|
|
||||||
// Is this a builtin function?
|
|
||||||
bool is_builtin();
|
|
||||||
|
|
||||||
// Apply this as a function to a list of arguments in a given environment.
|
// Apply this as a function to a list of arguments in a given environment.
|
||||||
MlValue apply(std::vector<MlValue> args, MlEnvironment &env);
|
MlValue apply(std::vector<MlValue> args, MlEnvironment &env);
|
||||||
|
|
||||||
// Evaluate this value as lisp code.
|
// Evaluate this value as lisp code.
|
||||||
MlValue eval(MlEnvironment &env);
|
MlValue eval(MlEnvironment &env);
|
||||||
|
|
||||||
|
bool is_builtin() const;
|
||||||
|
|
||||||
bool is_number() const;
|
bool is_number() const;
|
||||||
|
|
||||||
|
bool is_string() const;
|
||||||
|
|
||||||
// Get the boolean value of this value.
|
// Get the boolean value of this value.
|
||||||
bool as_bool() const;
|
bool as_bool() const;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue