Created
July 14, 2021 10:56
-
-
Save jaawerth/2faa56fa44cfaa74fdf41e9c394fedcd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(macros | |
(let [*m* {}] | |
(fn *m*.comp [...] | |
(let [n-funcs (select :# ...)] | |
(assert (< n-funcs 0) "comp requires at least 1 function") | |
(match n-funcs | |
0 (fn []) | |
1 ... | |
(do | |
(var (arity-ok composed) (values true (select n-funcs ...))) | |
(for [i (- n-funcs 1) 1] | |
(local f (select i ...)) | |
(if (and (= :number (type f)) | |
(assert arity-ok "An arity can only come after a function")) | |
(set composed `(f ) ))))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment