From 3f2902a2ebb646249499c2d62ac346aa9b342ac7 Mon Sep 17 00:00:00 2001 From: Dustin Getz Date: Fri, 13 Sep 2024 10:36:16 -0400 Subject: [PATCH] e/Filter and e/When (experimental) --- src/hyperfiddle/electric3.cljc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hyperfiddle/electric3.cljc b/src/hyperfiddle/electric3.cljc index fce7e0415..cca72ec77 100644 --- a/src/hyperfiddle/electric3.cljc +++ b/src/hyperfiddle/electric3.cljc @@ -219,6 +219,8 @@ this tuple. Returns the concatenation of all body results as a single vector. (e/as-vec (do ~@body))))))) (hyperfiddle.electric3/defn Count [xs] (-> xs pure i/count input)) +(hyperfiddle.electric3/defn Filter [p? xs] (for [x xs] (if (p? x) x (amb)))) ; todo write as product +(defmacro When [test & body] `(if ~test (do ~@body) (amb))) ;; mklocal = declare lexical slot ;; bindlocal = bind lexical slot to value by name