forked from alex-eg/sex
17 lines
574 B
Org Mode
17 lines
574 B
Org Mode
* threading-macros
|
|
~->~ passes a value through a chain of forms, each step taking what came
|
|
before it as its first argument, so the chain reads in the order it
|
|
happens instead of inside out. Clojure spells it this way and this is
|
|
the same thing:
|
|
|
|
#+begin_src scheme
|
|
(import threading-macros)
|
|
|
|
(-> 5 double-it (add 3) double-it) ; (double-it (add (double-it 5) 3))
|
|
(-> lp (. a x)) ; lp->a->x
|
|
(-> q .length-sq) ; a method is a step like any other
|
|
#+end_src
|
|
|
|
A step that is not a list is a call of one argument: ~(-> x f)~ is
|
|
~(f x)~.
|