Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the arrow-macros Reference Manual, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 11:42:42 2020 GMT+0.
• Introduction | What arrow-macros is all about | |
• Systems | The systems documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
Arrow-macros provides clojure-like arrow macros (ex. ->, ->>) and diamond wands in swiss-arrows (https://github.com/rplevy/swiss-arrows).
(-> 1 (+ 2 3) #'1+ 1+ (lambda (x) (+ x 1)) (1+)) ; => 10
(->> (list 1 2 3 4 5)
(mapcar #'1+)
(reduce #'+)) ; => 20
(-<> "abcdefghijklmnopqrstuvwxyz"
(ppcre:scan-to-strings "j.*q" <>)
(sort #'string>)
(string-upcase :end 1)) ; => "Qponmlkj"
(-> (get-some-webpage-uri id)
drakma:http-request
babel:octets-to-string
json->list)
(ql:quickload :arrow-macros)
These macro functions are equivalent to clojure's ones.
These wonderful macros are developed in clojure's library swiss-arrows (https://github.com/rplevy/swiss-arrows). These macro functions are almost equivalent to them too.
(-<> 1 1+ #'1+ (1+) (lambda (x) (1+ x))) ; => 5
(-<> 1
(+ 2) ; => (+ 1 2)
(+ 3 <>) ; => (+ 3 (+ 1 2))
(+ 4) ; => (+ (+ 3 (+ 1 2) 4) => 10
(-<>> 1
(+ 2) ; => (+ 2 1)
(+ <> 3) ; => (+ (+ 2 1) 3)
(+ 4) ; => (+ 4 (+ (+ 2 1) 3)) => 10
Arrow-macros can also write nested diamond-wands like:
(-<>> (list 1 2 3)
(mapcar #'1+)
(-<> <> (sort #'>))
(mapcar #'1+)) ; => (5 4 3)
(-<> 1 (+ <> <>) (-<> (+ <> <> <>))) ; => 6
Be aware that the inner diamond-wand can refer to outer diamond symbol <> only in initial form.
Diamond wand can write multiple <> symbols in each expression.
(let ((x 0))
(list (-<> x
incf
(+ <> <>)
(+ <> <>)) ; => (+ (+ (incf x) (incf x)) (+ (incf x) (incf x))) => 10
x)) ; => (10 4)
This means some expressions in diamond wands can be evaluated for 2 or more times. If you use expressions which have side effects in diamond wands, there is a risk that might happen what you don't intend. One solution is you don't use diamond wands for expressions containing side effects. Another solution is using <!> symbol in diamond wands. This may be a unique feature in this library. <!> symbol ensure previous expression evaluted only once.
(let ((x 0))
(list (-<> x
incf <!>
(+ <> <>)
(+ <> <>))
x)) ; => (4 1)
(-<> (drakma:http-request <some-address>) <!>
(some-converter <> :encode (detect-encoding-of <>))) ; => this sends http request only once
Original library (https://github.com/rplevy/swiss-arrows) doesn't have this feature. I need this for my local small project so add it. It doesn't change the original diamond wand behavior but if you find any problems or improvements, please report me.
(Nov 26, 2020)
For author's misunderstading, diamond wand specification had been uncorrect (see issue #3). It has been fixed and the changes can make this library independence from code walker so arrow-macros is now smaller and slimer than old version.
(June 2015)
Build verified on sbcl, ccl, abcl, allegro, clisp. But diamond-wand tests fail on abcl, allegro, clisp. Failed on ecl while loading hu.dwim.walker. Not tested on cmucl. (contributed by guicho271828, thanks!)
(May 7, 2015)
On sbcl for windows, arrow-macros can be built now.
Arrow-macros is under the MIT License, see LICENSE file.
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The arrow-macros system |
hipeta
MIT
arrow-macros provides clojure-like arrow macros and diamond wands.
alexandria
arrow-macros.asd (file)
arrow-macros.lisp (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The arrow-macros.asd file | ||
• The arrow-macros/arrow-macros.lisp file |
Next: The arrow-macros/arrow-macros․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
arrow-macros.asd
arrow-macros (system)
Previous: The arrow-macros․asd file, Up: Lisp files [Contents][Index]
arrow-macros (system)
arrow-macros.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The arrow-macros-asd package | ||
• The arrow-macros package |
Next: The arrow-macros package, Previous: Packages, Up: Packages [Contents][Index]
arrow-macros.asd
Previous: The arrow-macros-asd package, Up: Packages [Contents][Index]
arrow-macros.lisp (file)
common-lisp
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported macros |
Previous: Exported definitions, Up: Exported definitions [Contents][Index]
arrow-macros.lisp (file)
arrow-macros.lisp (file)
arrow-macros.lisp (file)
arrow-macros.lisp (file)
arrow-macros.lisp (file)
arrow-macros.lisp (file)
arrow-macros.lisp (file)
arrow-macros.lisp (file)
arrow-macros.lisp (file)
arrow-macros.lisp (file)
arrow-macros.lisp (file)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal special variables | ||
• Internal functions |
Next: Internal functions, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
arrow-macros.lisp (file)
Previous: Internal special variables, Up: Internal definitions [Contents][Index]
arrow-macros.lisp (file)
arrow-macros.lisp (file)
arrow-macros.lisp (file)
arrow-macros.lisp (file)
arrow-macros.lisp (file)
arrow-macros.lisp (file)
arrow-macros.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | A F L |
---|
Jump to: | A F L |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | -
A C D F H M R S |
---|
Jump to: | -
A C D F H M R S |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
S |
---|
Index Entry | Section | ||
---|---|---|---|
| |||
* | |||
*diamond-wands* : | Internal special variables | ||
| |||
S | |||
Special Variable, *diamond-wands* : | Internal special variables | ||
|
Jump to: | *
S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | A P S |
---|
Jump to: | A P S |
---|