From e3d875d48acae3a1d40ea7de33b12567c855c974 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sat, 22 Feb 2025 23:03:23 +0000 Subject: Implement specific function generation functions for each threading macro --- lib/macros.lisp | 20 +++++++++++++++++--- packages.lisp | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/macros.lisp b/lib/macros.lisp index d925ac5..c60b867 100644 --- a/lib/macros.lisp +++ b/lib/macros.lisp @@ -101,11 +101,25 @@ arguments `LAMBDA-LIST' with body `BODY'." (defun ,name ,lambda-list ,@body))) -(defmacro $ (capture &rest forms) +(defmacro $-> (capture &rest forms) "Given a sequence of FORMS, return a unary function which applies each form -sequentially" +sequentially via -->" `(lambda (,capture) - (->> ,capture ,@forms))) + (--> ,capture ,capture ,@forms))) + +(defmacro $<> (&rest forms) + "Given a sequence of FORMS, return a unary function which applies each form +sequentially via -<>" + (let ((capture (gensym))) + `(lambda (,capture) + (-<> ,capture ,@forms)))) + +(defmacro $>> (&rest forms) + "Given a sequence of FORMS, return a unary function which applies each form +sequentially via ->>" + (let ((capture (gensym))) + `(lambda (,capture) + (->> ,capture ,@forms)))) (defmacro alist-val (key alist) "Helper macro for getting the value of KEY in ALIST." diff --git a/packages.lisp b/packages.lisp index a6db383..594dda5 100644 --- a/packages.lisp +++ b/packages.lisp @@ -24,7 +24,7 @@ :--> :->> :-<> :-> :fn :while :alist-val - :$)) + :$-> :$>> :$<>)) (defpackage cantedraw.lib.functions (:nicknames :5d-lib.functions) -- cgit v1.2.3-13-gbd6f