From 08131d3e4ead2205593c9391f480289741cffa61 Mon Sep 17 00:00:00 2001 From: VaclavT Date: Sat, 15 May 2021 23:43:24 +0200 Subject: [PATCH] MlValue::is_string added --- ml.cpp | 6 +++++- ml.h | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ml.cpp b/ml.cpp index 77792a2..2b64e98 100644 --- a/ml.cpp +++ b/ml.cpp @@ -168,7 +168,7 @@ std::vector MlValue::get_used_atoms() { } // Is this a builtin function? -bool MlValue::is_builtin() { +bool MlValue::is_builtin() const { return type == BUILTIN; } @@ -176,6 +176,10 @@ bool MlValue::is_number() const { return type == INT || type == FLOAT; } +bool MlValue::is_string() const { + return type == STRING; +} + // Get the "truthy" boolean value of this value. bool MlValue::as_bool() const { return type != NIL && *this != MlValue(0l); // TODO remove 0 as false diff --git a/ml.h b/ml.h index e0a96b3..056276c 100644 --- a/ml.h +++ b/ml.h @@ -136,17 +136,18 @@ public: std::vector 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. MlValue apply(std::vector args, MlEnvironment &env); // Evaluate this value as lisp code. MlValue eval(MlEnvironment &env); + bool is_builtin() const; + bool is_number() const; + bool is_string() const; + // Get the boolean value of this value. bool as_bool() const;