From f969fb69e16f08029c20c5758aa1f852ca35e988 Mon Sep 17 00:00:00 2001 From: primo-ppcg Date: Fri, 1 Sep 2023 13:04:53 +0700 Subject: [PATCH] add `lengthable?` --- src/core/corelib.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/corelib.c b/src/core/corelib.c index c89787b9..5e46f33e 100644 --- a/src/core/corelib.c +++ b/src/core/corelib.c @@ -680,6 +680,13 @@ JANET_CORE_FN(janet_core_is_dictionary, return janet_wrap_boolean(janet_checktypes(argv[0], JANET_TFLAG_DICTIONARY)); } +JANET_CORE_FN(janet_core_is_lengthable, + "(lengthable? x)", + "Check if x is a bytes, indexed, or dictionary.") { + janet_fixarity(argc, 1); + return janet_wrap_boolean(janet_checktypes(argv[0], JANET_TFLAG_LENGTHABLE)); +} + JANET_CORE_FN(janet_core_signal, "(signal what x)", "Raise a signal with payload x. ") { @@ -1079,6 +1086,7 @@ static void janet_load_libs(JanetTable *env) { JANET_CORE_REG("bytes?", janet_core_is_bytes), JANET_CORE_REG("indexed?", janet_core_is_indexed), JANET_CORE_REG("dictionary?", janet_core_is_dictionary), + JANET_CORE_REG("lengthable?", janet_core_is_lengthable), JANET_CORE_REG("slice", janet_core_slice), JANET_CORE_REG("range", janet_core_range), JANET_CORE_REG("signal", janet_core_signal),