Skip to content

Commit

Permalink
Added apply macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Yarin Heffes committed Sep 13, 2024
1 parent ee082e7 commit fb938cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/language-macros.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ to
(cl:assert (cl:<= 2 (cl:list-length items)))
`(nest ,@(cl:reverse items)))

(cl:defmacro apply (cl:&rest items)
"A syntactic convenience for function application. Transform
(APPLY w x y z)
to
(fn (f) (f w x y z))."

(alexandria:with-gensyms (f)
`(fn (,f)
(,f ,@items))))

(cl:defmacro .< (cl:&rest items)
"Right associative compose operator. Creates a new functions that will run the
functions right to left when applied. This is the same as the NEST macro without supplying
Expand Down
1 change: 1 addition & 0 deletions src/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
#:unwrap-as
#:nest
#:pipe
#:apply
#:.<
#:.>
#:make-list
Expand Down

0 comments on commit fb938cb

Please sign in to comment.