mirror of
https://github.com/carp-lang/Carp.git
synced 2024-10-26 05:45:37 +03:00
macros: add comp
This commit is contained in:
parent
bd397f8d50
commit
65db2bc2a8
@ -372,3 +372,13 @@ The expression must be evaluable at compile time.")
|
||||
(list 'if (list 'defined? var)
|
||||
()
|
||||
(list 'defdynamic var expr)))
|
||||
|
||||
(defndynamic comp-internal [sym fns]
|
||||
(if (= (length fns) 0)
|
||||
sym
|
||||
(list (car fns) (comp-internal sym (cdr fns)))))
|
||||
|
||||
(doc comp "composes the functions `fns` into one `fn`.")
|
||||
(defmacro comp [:rest fns]
|
||||
(let [x (gensym)]
|
||||
(list 'fn [x] (comp-internal x fns))))
|
||||
|
Loading…
Reference in New Issue
Block a user