df57ee048761

Unfuck `-<>`
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 21 Jan 2017 12:27:33 +0000
parents 8b5c27a2d2de
children 4d4ad6ac3bf6
branches/tags (none)
files losh.lisp

Changes

--- a/losh.lisp	Sat Jan 21 11:29:14 2017 +0000
+++ b/losh.lisp	Sat Jan 21 12:27:33 2017 +0000
@@ -1,18 +1,18 @@
 (in-package :losh)
 
 ;;;; Sanity -------------------------------------------------------------------
-(defmacro -<> (&rest forms)
+(defmacro -<> (expr &rest forms)
   "Thread the given forms, with `<>` as a placeholder."
   ;; I am going to lose my fucking mind if I have to program lisp without
   ;; a threading macro, but I don't want to add another dep to this library, so
   ;; here we are.
-  (if (null forms)
-    '<>
-    (destructuring-bind (form . remaining) forms
-      `(let ((<> ,(if (symbolp form)
-                    `(,form <>)
-                    form)))
-         (-<> ,@remaining)))))
+  `(let* ((<> ,expr)
+          ,@(mapcar (lambda (form)
+                      (if (symbolp form)
+                        `(<> (,form <>))
+                        `(<> ,form)))
+                    forms))
+     <>))
 
 
 ;;;; Types --------------------------------------------------------------------