From 74d64a85bb89b9f59776f50e72e06db4491736ff Mon Sep 17 00:00:00 2001 From: Veit Heller Date: Tue, 13 Jul 2021 18:04:58 +0200 Subject: [PATCH] feat: add Dynamic.proc? (#1278) --- core/Dynamic.carp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/Dynamic.carp b/core/Dynamic.carp index ccce54fe..b9dee77e 100644 --- a/core/Dynamic.carp +++ b/core/Dynamic.carp @@ -2,6 +2,12 @@ (defmodule Dynamic ;; Functions for doing things at the REPL and during compile time. + (doc proc? "checks whether `x` is callable.") + (defndynamic proc? [x] + (or + (List.in? (dynamic-type x) '(fn closure)) + (let [s (s-expr x)] + (and (not (empty? s)) (= 'dynamic (dynamic-type (car s))))))) (doc nil "is the value `nil`, i.e. the empty list.") (defdynamic nil '())