Use #* assignments instead of head-tail
This commit is contained in:
parent
e6aac2308a
commit
7aaece3725
@ -70,9 +70,6 @@
|
|||||||
(with-decorator (method-decorator ~name)
|
(with-decorator (method-decorator ~name)
|
||||||
(defn ~name ~params ~@body))))
|
(defn ~name ~params ~@body))))
|
||||||
|
|
||||||
(defn head-tail [l]
|
|
||||||
(, (get l 0) (cut l 1)))
|
|
||||||
|
|
||||||
(defmacro defn [name &rest bodies]
|
(defmacro defn [name &rest bodies]
|
||||||
(setv arity-overloaded? (fn [bodies]
|
(setv arity-overloaded? (fn [bodies]
|
||||||
(if (isinstance (first bodies) HyString)
|
(if (isinstance (first bodies) HyString)
|
||||||
@ -83,10 +80,10 @@
|
|||||||
(do
|
(do
|
||||||
(setv comment (HyString))
|
(setv comment (HyString))
|
||||||
(if (= (type (first bodies)) HyString)
|
(if (= (type (first bodies)) HyString)
|
||||||
(setv [comment bodies] (head-tail bodies)))
|
(setv [comment #* bodies] bodies))
|
||||||
(+ '(do (import [hy.contrib.multi [MultiDispatch]])) (lfor
|
(+ '(do (import [hy.contrib.multi [MultiDispatch]])) (lfor
|
||||||
[let-binds #* body] bodies
|
[let-binds #* body] bodies
|
||||||
`(with-decorator MultiDispatch (defn ~name ~let-binds ~comment ~@body)))))
|
`(with-decorator MultiDispatch (defn ~name ~let-binds ~comment ~@body)))))
|
||||||
(do
|
(do
|
||||||
(setv [lambda-list body] (head-tail bodies))
|
(setv [lambda-list #* body] bodies)
|
||||||
`(setv ~name (fn* ~lambda-list ~@body)))))
|
`(setv ~name (fn* ~lambda-list ~@body)))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user