From f331192861d8ba02af7fd47f2e0c6d6db7515007 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 20 Jun 2024 23:26:18 +0100 Subject: add (if cond if-true if-false) builtin --- val.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'val.c') diff --git a/val.c b/val.c index 6f1dd9e..19f96a0 100644 --- a/val.c +++ b/val.c @@ -75,6 +75,12 @@ void println_val(Val v) { putchar('\n'); } +bool is_truthy(Val v) { + if (IS_NIL(v) || ( IS_BOOL(v) && AS_BOOL(v) == false)) + return false; + return true; +} + const char *typename_str(Val v) { switch(v.ty) { -- cgit v1.2.3