From fad1a27439f8975c510717b46046ba112dbea33e Mon Sep 17 00:00:00 2001 From: nicolas-p Date: Sun, 26 Apr 2015 18:35:46 +0200 Subject: [PATCH] Docs for ap-pipe and ap-compose Added docs for the ap-pipe and ap-compose anaphoric macros. --- docs/contrib/anaphoric.rst | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/docs/contrib/anaphoric.rst b/docs/contrib/anaphoric.rst index 4ab30d9..750a470 100644 --- a/docs/contrib/anaphoric.rst +++ b/docs/contrib/anaphoric.rst @@ -195,3 +195,36 @@ first element instead. This exposes the element being iterated as =>(ap-reduce (+ it acc) (range 10)) 45 + + +.. _ap-pipe: + +ap-pipe +========= + +Usage ``(ap-pipe value form1 form2 ...)`` + +Applies several forms in series to a value from left to right. The special variable ``ìt`` in each form is replaced by the result of the previous form. + +.. code-block:: hy + + => (ap-pipe 3 (+ it 1) (/ 5 it)) + 1.25 + => (ap-pipe [4 5 6 7] (list (rest it)) (len it)) + 3 + + +.. _ap-compose: + +ap-compose +========= + +Usage ``(ap-compose form1 form2 ...)`` + +Returns a function which applies several forms in series from left to right. The special variable ``ìt`` in each form is replaced by the result of the previous form. + +.. code-block:: hy + + => (def op (ap-compose (+ it 1) (* it 3))) + => (op 2) + 9