Skip to content

Instantly share code, notes, and snippets.

@jaawerth
Created July 14, 2021 10:56
Show Gist options
  • Save jaawerth/2faa56fa44cfaa74fdf41e9c394fedcd to your computer and use it in GitHub Desktop.
Save jaawerth/2faa56fa44cfaa74fdf41e9c394fedcd to your computer and use it in GitHub Desktop.
(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